help with histogram

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

help with histogram

plazajp
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: help with histogram

andy buckle
On Wed, Jun 8, 2011 at 12:07 PM, plazajp <[hidden email]> wrote:

> Hi everyone, I'm new using Octave and I have a problem. Maybe it's easy to
> solve, but I've been unable to do it!
>
>  I need to show the histogram of an uint8 image ('im'), but octave only
> allows me to show it if the image type is changed to double. I don't want
> that, because I want every bin to be on the vector 1:256, not between 0 and
> 1. I've tried to do imhist (im), imhist(im, 1:256), and everything I've
> thought of and I haven't been able to get it. I suppose there has to be a
> way to do it, so I guess someone will be able to tell me where I'm failing.
>
> Thank you for the attention, and I hope someone can tell me the answer!

You can cast to double without renormalizing the range to be 0-1. I
don't understand.

im=floor(rand(16)*256);
hist(im(:), 1:256);

I guess you will need the first arg to hist to be a vector, hence the
(:). Is that what is throwing you?

--
/* andy buckle */
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: help with histogram

Francesco Potortì
In reply to this post by plazajp
> I need to show the histogram of an uint8 image ('im'), but octave only
>allows me to show it if the image type is changed to double. I don't want
>that, because I want every bin to be on the vector 1:256, not between 0 and
>1. I've tried to do imhist (im), imhist(im, 1:256)

Change it to double, then:

imhist(256*im, 1:256)

--
Francesco Potortì (ricercatore)        Voice:  +39.050.315.3058 (op.2111)
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Fax:    +39.050.315.2040
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: help with histogram

grizzly101
In reply to this post by andy buckle
I know this is an old post, but I finally figured out why imhist wasn't working for uint8 images.  Imhist.m uses the command hist(I(:), bins) to generate the histogram.  Bins is defined as an integer value of 256 when used for intensity images.  To correct this, open the imhist file and change the bins = 256 line to bins = 0:256 and imhist will not work for grayscale images of uint8 type.  I was using a bmp file as my input, but I noticed the same issue for tif and png until I changed that line.

I hope this helps, and if this is messing up the original intent of imhist, someone please let me know...I'm a noob with matlab/octave and image processing.  

thanks,
Grizzly

Reply | Threaded
Open this post in threaded view
|

Re: help with histogram

Carnë Draug-2
On 12 February 2012 22:09, grizzly101 <[hidden email]> wrote:

> I know this is an old post, but I finally figured out why imhist wasn't
> working for uint8 images.  Imhist.m uses the command hist(I(:), bins) to
> generate the histogram.  Bins is defined as an integer value of 256 when
> used for intensity images.  To correct this, open the imhist file and change
> the bins = 256 line to bins = 0:256 and imhist will not work for grayscale
> images of uint8 type.  I was using a bmp file as my input, but I noticed the
> same issue for tif and png until I changed that line.
>
> I hope this helps, and if this is messing up the original intent of imhist,
> someone please let me know...I'm a noob with matlab/octave and image
> processing.
>
> thanks,
> Grizzly

Hi Grizzly

the imhist on the repository is already different from the last
released version. It fixes some problems (but introduced another).

You may want to check it out here
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/image/inst/imhist.m?revision=9621&view=markup

Carnë
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave