Re: Joint Histogram
- To: mathgroup at smc.vnet.net
- Subject: [mg81153] Re: Joint Histogram
- From: "Mariusz Jankowski" <mjankowski at usm.maine.edu>
- Date: Fri, 14 Sep 2007 03:34:25 -0400 (EDT)
- Organization: University of Southern Maine
- References: <fcb3gv$fg5$1@smc.vnet.net>
The first answer is to use function JointImageHistogram in the Digital Image Processing package. However, the following will work: In[1]:= beans = Import["http://www.ee.usm.maine.edu/courses/ele489/data/beans.tif"] In[2]:= data = beans[[1, 1]]; In[3]:= {ydim, xdim} = Dimensions[data]; In[4]:= h = Table[0, {256}, {256}]; In[5]:= Do[ h[[data[[i, j, 1]] + 1, data[[i, j, 2]] + 1]] += 1, {i, ydim}, {j, xdim}] ... and display matrix h. Bye, Mariusz >>> On 9/13/2007 at 6:30 AM, in message <fcb3gv$fg5$1 at smc.vnet.net>, cimon<tamanna.arora at gmail.com> wrote: > Hello > > I am completely new to Mathematica > and trying to work with images in it. > > I am trying to create a joint histogram out of an image taking its red > and green channel. > I get this error > > Table::iterb: Iterator (i,1,ydim), does not have appropriate bounds. > Table::iterb: Iterator (i,1,ydim), does not have appropriate bounds. > > (see in code below) > > When I have just written the first five lines and i try to execute. i > dont get this error. > But when I have written the for loop and than i try to execute than I > get this error. > > > I am just not able to fix this out. > can somebody plese guide me with this. > ------------------------------------------------------------------------- > penny = Import["c:\penny.ppm"]; > Shallow[penny]; > data = penny[[1, 1]]; > > ydim = Dimensions[data][[1]]; > xdim = Dimensions[data][[2]]; > > Table::iterb: Iterator (i,1,ydim), does not have appropriate bounds. > Table::iterb: Iterator (i,1,ydim), does not have appropriate bounds. > > (* Create a Joint table > Go to each (i, j)th Location in red and green Channel > Get Pixel value from (i, j)th location from each red and green > channel > Use that as an index into > Joint Table and incerment the value at that index by 1 > *) > > Joint = Table[0, {ti, 1, 256}, {tb, 1, 256}]; > Dimensions[Joint]; > > > For[fi = 0, fi =E2=89=A4 xdim, fi++ > For[fj = 0, fj =E2=89=A4 ydim, fj++ > Joint[redChannel[[fi, fj]], greenChannel[[fi, fj]]] += > 1]]; > > Show[Graphics[Raster[Joint], AspectRatio -> 1, Axes -> True]] > > > ---------------------------------------------------------------------------= > ------------------------------------