From help-octave-request at bevo dot che dot wisc dot edu Wed Mar 10 12:54:15 2004 Subject: Re: imread image sizing From: Daniel J Sebald To: JD Cole Cc: Ross Vandegrift , help-octave@bevo.che.wisc.edu, octave-maintainers@bevo.che.wisc.edu Date: Wed, 10 Mar 2004 12:44:35 -0600 Allow me to elaborate on what JD said... I think I see what the issue is. I just looked inside the "image.m" file. There is a silly little unsuspecting variable called "zoom". Maybe a "help image" will describe what that is. Anyway, it looks like a parameter that if NOT specified will be chosen so that it always attempts a resolution of 350 x 600, but it uses rounding to the nearest integer. So in your case, Ross, the result is probably 1/2, i.e., the 320x240 you describe. My preference would be to simply set the zoom equal to 1.0 if the variable is not specified. Anyway... Since you cannot specify the zoom parameter in imshow() and pass it to image(), which imshow() uses, I suggest just using image() instead. Here are the three commands that imshow() uses if there are three arguments, i.e., R G B. [a1, a2] = rgb2ind (a1, a2, a3); colormap (a2); image (a1); So do those directly and change the last command so that it reads image([],[],a1,1); Hopefully that will force the 'x' and 'y' to be generated by the routine and force the resolution to stay just as it is. I'm not sure this truely allows RGB images. (Unless the colormap happens to be huge.) But, give that a try. Glad you pointed this out, because I too probably would have been bitten by this along the way. Dan JD Cole wrote: > Hi Ross, > I've come across this before too. If you follow the trail of > functions that 'imshow' actually uses, you'd see that after it creates > a colormap and an indexed image from the r/g/b parameters, it uses the > 'image' command to display them. 'image' takes a scale parameter, but > in this case, imshow doesn't pass one, in the case of no scale > parameter, 'image' decides to make a scaled image, hence, your > 320x240. You got a couple of choices, you could create you're own > version of 'imshow' and add a scale parameter, something like this > > imshow (a1, a2, a3, scale) > .... > .... > image (a1, scale) > .... > .... > or at the very least > > .... > image (a1, 1) > .... > > This problem bothers me often too, but I'm not sure what the > mainstream solution would be since changing the definition for > 'imshow', as distributed with octave, would break from compatibility > with other numerical programs which shall remain un-named. > > Maintainers have any thoughts? > > JD > Ross Vandegrift wrote: > >> Hello everyone, >> >> I'm working on an image analysis project, and am using imread to >> read in a color 640x480 JPEG file and sample some points. >> >> Oddly though, when read in and displayed, the graphic is >> displayed as 320x240. If I manually run "display eye.jpg", the image is >> loaded as 640x480. I've tried setting "-size 640x480" and "-sample >> 640x480" in the options, neither one helps. >> >> Here's how I'm loading/displaying my image: >> >> [red, green, blue] = imread('jpg:eye.jpg', ["-size 640x480";]); >> red = red / 255; >> blue = blue / 255; >> green = green / 255; >> imshow(red, green, blue) >> >> It's not a critical problem or anything - I'm still able to work >> on the project at 320x240, but is there something I can do to get >> 640x480? >> >> Thanks! >> >> > > > > -- Dan Sebald email: daniel DOT sebald AT ieee DOT org URL: http://acer-access DOT com/~dsebald AT acer-access DOT com/ ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------