reset password
Author Message
DavidGilbert
Posts: 40
Posted 12:14 Mar 13, 2012 |

I was loading the PGM file using the classes given and it wasn't showing any data.

I output all the parameters:

 

Name=lena.pgm
X=512
Y=512
Dim=0
 
If you notice, DIM is set at 0 and the read method doesn't have a default case.
 
So, I hard coded in Dim = 2, so it will read the data in.  After that, I started receiving negative entries in my Data2D array.  
 
What could I be doing wrong?

Update:  I see what it is, it's because the byte data type has an upper bound of 127 and lower bound of -128.  I'm not getting the integer values of it correctly.
 
Update 2:  It's not how I'm getting the integer values, we need to just get the value and add 128 to it.  If you look in pgm.java when it assigns the values, it's subtracting 128 to fit it into the byte bounds.
 
p.data2D[col][row]=(byte)(r.read()-128);
 
So, when we want to manipulate it, we need to remember to add 128.
Last edited by DavidGilbert at 12:25 Mar 13, 2012.
hpguo
Posts: 139
Posted 12:21 Mar 13, 2012 |

then use unsigned byte type.