octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: type handling bug?


From: John W. Eaton
Subject: Re: type handling bug?
Date: Tue, 26 May 2009 08:47:40 -0400

On 26-May-2009, Levente Torok wrote:

| > > im =imread("p1020037.jpg" );
| > > octave:10> sum(sum(im==0))
| > > ans = 16980
| > > 
| > > 
| > > 
| > > z=resize( im, s=rows(im)*columns(im),1 );
| > > octave:11> sum(sum(z==0))
| > > ans = 3144192
| > 
| > My guess is that you image is an RGB image (all JPEG's are RGB, right?).
| > This makes the image NxMx3, but you're treating it as being MxN. But I'm
| > just guessing here.
|  Wrong.
| 
| octave:17> size(im)
| ans =
| 
|    1536   2048
| 
| Instead of 
| octave:18> size(im)
| ans =
| 
|    1536   2048      3
| 
| Other ideas?

Yes.  As mentioned earlier, resize is probably not the function you
are looking for because it changes the size without preserving the
data.  Use "reshape (im, numel (im), 1)" or "im(:)" to convert your
array to a column vector.  The "im(:)" syntax is the normal way to do
this and should be faster than calling reshape.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]