[Date Index]
[Thread Index]
[Author Index]
Re: importing image and getting numbers from the gray intensity
*To*: mathgroup at smc.vnet.net
*Subject*: [mg49445] Re: importing image and getting numbers from the gray intensity
*From*: sean_incali at yahoo.com (sean kim)
*Date*: Tue, 20 Jul 2004 07:53:43 -0400 (EDT)
*References*: <cd5okp$b2c$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Hi everyone,
follow up on Paul's, George's Jerry's and Yas' suggestions.
Yes, it must be version dependent. I'm getting exactly what George is
getting as well.
In[4]:= $Version
Out[4]= 5.0 for Microsoft Windows (June 12, 2003)
And I named the input cell pixels, not pixel.
And I'm getting Raster instead of RasterArray object
I though I would be clever and change the Input to RasterArray, then
it brings back...
RasterArray::rscol: Expression 0.160784` at position {1, 1} in first
argument \
of RasterArray is not a valid color or gray-level directive
the numbers are not the same because I took the negative image from
Irfanview image viewer.
Also I noticed that if I take the negative image from irfanview and
save it as jpg, non of the suggestions work, but that's not related to
Mathematica, i don't think. it must be more of how irfanview encode the jpg
images...
IF I use Raster in your codes as George said and with the original
image,
In[16]:=
pixels = First[Cases[pixels, Raster[x__] :> x, Infinity]] /.
RGBColor[r_, g_, b_] :> (r + g + b)/3
ListDensityPlot[pixels,Mesh\[Rule]False];
then i get,
{{0.839216, 0.839216,0.807843,
...
long list of numbers
...
0.905882, 0.905882, 0.905882}}
and the the original plot.
here is something that is kinda weird for me,
if I repeat evaluate that cell,
In[18]:=
pixels = First[Cases[pixels, Raster[x__] :> x, Infinity]] /.
RGBColor[r_, g_, b_] :> (r + g + b)/3
ListDensityPlot[pixels,Mesh\[Rule]False];
From In[18]:=
First::first: {} has a length of zero and no first element
Out[18]=
First[{}]
From In[18]:=
DensityGraphics::gmat: First[{}] is not a rectangular array larger
than 2 x 2.
And both Jerry and Yas used the columns to find the lanes. After
trying the hint, I totally understand where you guys got the lane
numbers. It tells you right on the picture. Mathematica must have taken the
image and defined it in an array. so that the dimentions tells you how
many Rows and Columns are in the array (i guess?)
If I use a negative image, then the chromatograms you suggested looks
much better, as you get peaks instead of dips.
ListPlot3D[d, Mesh -> False, PlotRange -> All, AspectRatio ->
Automatic, ImageSize -> 400]
Above will really demonstrate the limitation of the gray levels human
eye can perceive. if you look at the center of the bands, they seem to
be of one intensity but Mathematica wil actually show you differing levels in
the form of peaks!
Anyway, thank you all very much.
I'm starting to appreciate the power of Mathematica. it's pretty amazing.
Even though I'm still not very good at it. (but I'm getting better
thanks to this group)
sean
Hi Paul (Jean and Sean),
Thanks for the clarification on how the function works. Also, from
your
post to Sean, I realize now that my issue was that my Mathematica
version:
In[8]:= (9:08:18 on 7/19/04)
$Version
Out[8]= (9:08:18 on 7/19/04)
5.0 for Microsoft Windows (June 10, 2003)
returns a "Raster" object. So simply using Raster[x__] in place of
RasterArray[x__] makes it work.
Thanks greatly,
George
-----Original Message-----
From: Paul Abbott [mailto:paul at physics.uwa.edu.au]
To: mathgroup at smc.vnet.net
Subject: [mg49445] RE: [mg49371] Re: importing image and getting numbers from
the
gray intensity
Hi George:
>I suppose this is terrible etiquette. I do not use post groups like
>this often. But, since I discovered this (through your "In and Out",
I
>have become rather addicted to the group.
I'm glad that you like MathGroup
>I am very interested in your response to this post. However, I do
not
>understand it. I am okay up to getting the following into my cell:
>
>pixels=Show[Graphics[{
>AbsoluteThickness[1],
>Raster[{
>{0.827451,.... 0.882353}},
>{{4, 4}, {254, 293}}]
>}], AspectRatio->1.156,
>PlotRange->{{4, 254}, {4, 293}},
>ImageSize->{250, 289}]
That looks fine to me.
>But, then I do not understand what part of this expression I assign
to
>"pixels".
As you have done above (typing "pixels=" into the InputForm cell).
>Perhaps my confusion is due to another issue, which is that I have
>never named a Cell, and therefore, I assume I should name part of the
>above expression "pixels". I made a couple of attempts, such as:
>
>pixels={{0.827451,.... 0.882353}};
>
>Or
>
>Pixels=Raster[{{0.827451,.... 0.882353}},{{4, 4}, {254, 293}}];
You could do either of these things. The idea I was presenting here is
to assign pixels to be the full graphic object (the result of the
Show[]
command) and then use Mathematica commands to extract from this
graphic
the information giving the colors by _overwriting_ the value of pixels
using
pixels = First[Cases[pixels, RasterArray[x__] :> x, Infinity]] /.
RGBColor[r_, g_, b_] :> (r + g + b)/3
>However, I am having no success with your function. Also, you can
see
>that part of my problem is that I do not understand in totality, the
>syntax of your command.
You can de-construct this command as follows. The inner part
Cases[pixels, RasterArray[x__] :> x, Infinity]
locates the RasterArray in pixels and saves its argument, x. There are
two parts to the RasterArray but only the first part is relevant,
extracted using First. Then, for each color primitive RGBColor[r, g,
b]
we average the r,g,b values using the replacement rule
RGBColor[r_, g_, b_] :> (r + g + b)/3
Then we call the result of this pixels (overwriting its earlier
value).
As a check we re-draw the picture
ListDensityPlot[pixels, Mesh -> False];
Cheers,
Paul
This message may contain privileged and/or confidential
information. If you have received this e-mail in error or are not the
intended
recipient, you may not use, copy, disseminate or distribute it; do not
open any attachments, delete it immediately from your system and
notify
the sender promptly by e-mail that you have done so. Thank you.
Prev by Date:
**Re: FindRoot s all**
Next by Date:
**elements of cultural strength from the von Bertalanffy standpoint**
Previous by thread:
**Re: importing image and getting numbers from the gray intensity**
Next by thread:
**Re: Re: importing image and getting numbers from the gray intensity**
| |