<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108</link>
    <title>MATLAB Central Newsreader - Area of specific pixel color?</title>
    <description>Feed for thread: Area of specific pixel color?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 29 Mar 2008 08:25:03 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#423452</link>
      <author>Dagher Dagher</author>
      <description>Thank You for all the information imageanalyst  i'll check &lt;br&gt;
out the link you've given and post, hope i'll be able to do &lt;br&gt;
it &lt;br&gt;
thanx again &lt;br&gt;
bobby&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sat, 29 Mar 2008 00:57:20 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#423430</link>
      <author>ImageAnalyst</author>
      <description>On Mar 28, 3:26=A0pm, "Dagher Dagher" &amp;lt;bobid...@hotmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; hello allen,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; i've been searching over the net to calculate in a picture&lt;br&gt;
&amp;gt; the area covered by a certain color, and i found ur post,&lt;br&gt;
&amp;gt; since i'm not a matlab expert (only done some image&lt;br&gt;
&amp;gt; processing) i wonder if you can help solve the issue,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thank You&lt;br&gt;
&amp;gt; bobby&lt;br&gt;
&lt;br&gt;
bobby/Dagher Dagher&lt;br&gt;
I don't think Allen is doing what you want to do.  He's painting over&lt;br&gt;
some area with a particular color and then finding that area.  That&lt;br&gt;
would work for you only if the color you were looking for was a&lt;br&gt;
certain very specific RGB triplet, which I doubt it is.  You probably&lt;br&gt;
want to search for some range of colors in your image, not one very&lt;br&gt;
specific color such as (100, 150, 200).  To do that, the usual&lt;br&gt;
starting place is to convert your image into HSV, HSL, or HSI color&lt;br&gt;
space (see &lt;a href="http://www.easyrgb.com/math.html),"&gt;http://www.easyrgb.com/math.html),&lt;/a&gt; and then set up some&lt;br&gt;
threshold ranges that will apply to each of the H band, the S (also&lt;br&gt;
called C for Chroma) band, and the Intensity or Value band.  Then you&lt;br&gt;
simply AND all the thresholded images for each color space together&lt;br&gt;
and call bwlabel() and regionprops().  It can get more complicated&lt;br&gt;
than that but that's the starter version.&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 28 Mar 2008 19:26:02 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#423391</link>
      <author>Dagher Dagher</author>
      <description>hello allen, &lt;br&gt;
&lt;br&gt;
i've been searching over the net to calculate in a picture &lt;br&gt;
the area covered by a certain color, and i found ur post, &lt;br&gt;
since i'm not a matlab expert (only done some image &lt;br&gt;
processing) i wonder if you can help solve the issue, &lt;br&gt;
&lt;br&gt;
Thank You&lt;br&gt;
bobby &lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 25 Mar 2008 01:48:05 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422610</link>
      <author>Allen</author>
      <description>Hi Walter,&lt;br&gt;
&lt;br&gt;
You're very right to be concerned about the foreshortening.  Basically, &lt;br&gt;
due to the projection of the surface onto the view-plane (since I'm &lt;br&gt;
looking down the z-axis), the areas will be altered into their &lt;br&gt;
projection.  If the selection algorithm is exactly perfect, then I'll &lt;br&gt;
get exactly the area of desire, and the foreshortening will not affect &lt;br&gt;
the results.  However, if there is some error in the selection process, &lt;br&gt;
you're absolutely correct.&lt;br&gt;
&lt;br&gt;
I determine bounds for the selection angles (surface normals), and this &lt;br&gt;
highlights the regions of interest for me.  These bounds are the perfect &lt;br&gt;
way to express your error as you suggested.  I'll definitely implement &lt;br&gt;
that in my work!&lt;br&gt;
&lt;br&gt;
Thanks for your thoughts, Walter!  I appreciate them!  :)&lt;br&gt;
-Allen&lt;br&gt;
&lt;br&gt;
Walter Roberson wrote:&lt;br&gt;
&amp;gt; I am concerned about the foreshortened areas. I see that there&lt;br&gt;
&amp;gt; are corrections for it posted ("divide by the cosine of the angle")&lt;br&gt;
&amp;gt; but there will be angles for which there would be considerable&lt;br&gt;
&amp;gt; error inherent in that process. In your particular application,&lt;br&gt;
&amp;gt; would it make sense to produce an error estimate as part of&lt;br&gt;
&amp;gt; the output? For example "The boundary that would have produced&lt;br&gt;
&amp;gt; one less pixel coloured would have been Xn and the boundary&lt;br&gt;
&amp;gt; that would have produced one more pixel coloured would have been Xf&lt;br&gt;
&amp;gt; so the true area is between Xn/cos(angle) and Xf/cos(angle)" ??&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sat, 22 Mar 2008 20:43:22 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422321</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;frvesa$ol9$1@news.ks.uiuc.edu&amp;gt;,&lt;br&gt;
Allen  &amp;lt;ajhalldeleteme@gmail.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;Quick Q version:&lt;br&gt;
&amp;gt;	How does one determine the fractional pixel area of a color.  i.e., if &lt;br&gt;
&amp;gt;I highlight grains one color, how can I determine the area of the &lt;br&gt;
&amp;gt;colored portion in pixels?&lt;br&gt;
&lt;br&gt;
&amp;gt;ps- this is an attempt to measure the surface-area of facets in a grown &lt;br&gt;
&amp;gt;crystal.  The data is taken from an AFM, and I can highlight them based &lt;br&gt;
&amp;gt;on the surface-gradient information.  The resulting images in plan-view &lt;br&gt;
&amp;gt;will be flat (forshortened areas etc.)&lt;br&gt;
&lt;br&gt;
I am concerned about the foreshortened areas. I see that there&lt;br&gt;
are corrections for it posted ("divide by the cosine of the angle")&lt;br&gt;
but there will be angles for which there would be considerable&lt;br&gt;
error inherent in that process. In your particular application,&lt;br&gt;
would it make sense to produce an error estimate as part of&lt;br&gt;
the output? For example "The boundary that would have produced&lt;br&gt;
one less pixel coloured would have been Xn and the boundary&lt;br&gt;
that would have produced one more pixel coloured would have been Xf&lt;br&gt;
so the true area is between Xn/cos(angle) and Xf/cos(angle)" ??&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
amazon.com's top 8 books about "walter" are Kotzwinkle/ Gundy/ Colman's&lt;br&gt;
"Walter the Farting Dog"&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sat, 22 Mar 2008 18:55:48 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422307</link>
      <author>Allen</author>
      <description>Hi, Vihang and ImageAnalyst!&lt;br&gt;
&lt;br&gt;
Thank you guys a ton for more details about roipoly and region props!  I &lt;br&gt;
really appreciate it.  I'll be working more on this code this afternoon. &lt;br&gt;
&amp;nbsp;&amp;nbsp;So, the pointers are greatly appreciated.  :)&lt;br&gt;
&lt;br&gt;
Thanks so much for the help!&lt;br&gt;
-Allen&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
------&lt;br&gt;
a.s.p. Brother of the Briar&lt;br&gt;
May 2001&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 21 Mar 2008 17:46:09 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422173</link>
      <author>ImageAnalyst</author>
      <description>On Mar 21, 12:51=A0am, Allen &amp;lt;ajhalldelet...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi guys,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Quick Q version:&lt;br&gt;
&amp;gt; =A0 =A0 =A0 =A0 How does one determine the fractional pixel area of a colo=&lt;br&gt;
r. =A0i.e., if&lt;br&gt;
&amp;gt; I highlight grains one color, how can I determine the area of the&lt;br&gt;
&amp;gt; colored portion in pixels?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Longer Q version:&lt;br&gt;
&amp;gt; =A0 =A0 =A0 =A0 I'm doing something complex (finding the surface area of a=&lt;br&gt;
&amp;nbsp;tilted&lt;br&gt;
&amp;gt; segment of an image)... but I think it can be done very simply.&lt;br&gt;
&amp;gt; =A0 =A0 =A0 =A0 I have a method to highlight only the area of interest, an=&lt;br&gt;
d now I want&lt;br&gt;
&amp;gt; to determine the area which is highlighted. =A0I'm assuming this will be&lt;br&gt;
&amp;gt; in pixels x pixels of the image, but can convert this easily to&lt;br&gt;
&amp;gt; real-space (as well as use the cosine of the tilt to give me the real area=&lt;br&gt;
).&lt;br&gt;
&amp;gt; =A0 =A0 =A0 =A0 So, is there a good way to get image information about are=&lt;br&gt;
as&lt;br&gt;
&amp;gt; highlighted with specific colors etc.? =A0If I painted one section of the&lt;br&gt;
&amp;gt; image all red, for instance, could I determine the pixel x pixel area?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks a ton for your help and thoughts, everyone!! =A0:)&lt;br&gt;
&amp;gt; -Allen&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ps- this is an attempt to measure the surface-area of facets in a grown&lt;br&gt;
&amp;gt; crystal. =A0The data is taken from an AFM, and I can highlight them based&lt;br&gt;
&amp;gt; on the surface-gradient information. =A0The resulting images in plan-view&lt;br&gt;
&amp;gt; will be flat (forshortened areas etc.)&lt;br&gt;
&lt;br&gt;
---------------------------------------------------------------------&lt;br&gt;
Allen:&lt;br&gt;
Rather than manually paint the image you cold also try the roipoly&lt;br&gt;
function,  This will let you outline an area.  Then convert the area&lt;br&gt;
to a binary image and call bwlabel and then regionprops.&lt;br&gt;
&lt;br&gt;
Alternatively you could paint a color on the image (maybe by making a&lt;br&gt;
modification to freehanddraw macro on the user file exchange), and&lt;br&gt;
then threshold each color band, something like&lt;br&gt;
paintcolor =3D [1 1 1];&lt;br&gt;
paintedRegion =3D imageArray(:,:,1) =3D=3D paintcolor(1) &amp;&amp; imageArray(:,:,&lt;br&gt;
2) =3D=3D paintcolor(2) &amp;&amp; imageArray(:,:,3) =3D=3D paintcolor(3)&lt;br&gt;
areaOfPaintedRegion =3D sum(sum(paintedRegion));&lt;br&gt;
That's the area of the projected region.  If it's tilted away from the&lt;br&gt;
screen by an angle theta, then to get then you need to divide by the&lt;br&gt;
cosine of the angle to get the actual area as if it weren't tilted.&lt;br&gt;
actualArea =3D areaOfPaintedRegion / cos(theta)&lt;br&gt;
and if the angle is not a single angle, but a more general tilt, it&lt;br&gt;
gets more complicated.&lt;br&gt;
&lt;br&gt;
You might have to take care about whether the image and/or the paint&lt;br&gt;
color is to be normalized to the 0-1 range or if it can stay in the&lt;br&gt;
0-255 range - that's always a watchout in MATLAB.&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 21 Mar 2008 06:44:02 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422096</link>
      <author>Vihang Patil</author>
      <description>Allen &amp;lt;ajhalldeleteme@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;frvesa$ol9$1@news.ks.uiuc.edu&amp;gt;...&lt;br&gt;
&amp;gt; Hi guys,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Quick Q version:&lt;br&gt;
&amp;gt; 	How does one determine the fractional pixel area &lt;br&gt;
of a color.  i.e., if &lt;br&gt;
&amp;gt; I highlight grains one color, how can I determine the &lt;br&gt;
area of the &lt;br&gt;
&amp;gt; colored portion in pixels?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Longer Q version:&lt;br&gt;
&amp;gt; 	I'm doing something complex (finding the surface &lt;br&gt;
area of a tilted &lt;br&gt;
&amp;gt; segment of an image)... but I think it can be done very &lt;br&gt;
simply.&lt;br&gt;
&amp;gt; 	I have a method to highlight only the area of &lt;br&gt;
interest, and now I want &lt;br&gt;
&amp;gt; to determine the area which is highlighted.  I'm &lt;br&gt;
assuming this will be &lt;br&gt;
&amp;gt; in pixels x pixels of the image, but can convert this &lt;br&gt;
easily to &lt;br&gt;
&amp;gt; real-space (as well as use the cosine of the tilt to &lt;br&gt;
give me the real area).&lt;br&gt;
&amp;gt; 	So, is there a good way to get image information &lt;br&gt;
about areas &lt;br&gt;
&amp;gt; highlighted with specific colors etc.?  If I painted one &lt;br&gt;
section of the &lt;br&gt;
&amp;gt; image all red, for instance, could I determine the pixel &lt;br&gt;
x pixel area?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks a ton for your help and thoughts, everyone!!  :)&lt;br&gt;
&amp;gt; -Allen&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ps- this is an attempt to measure the surface-area of &lt;br&gt;
facets in a grown &lt;br&gt;
&amp;gt; crystal.  The data is taken from an AFM, and I can &lt;br&gt;
highlight them based &lt;br&gt;
&amp;gt; on the surface-gradient information.  The resulting &lt;br&gt;
images in plan-view &lt;br&gt;
&amp;gt; will be flat (forshortened areas etc.)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Hello Allen&lt;br&gt;
If you could highlight the area of interest, then it means &lt;br&gt;
that you know that threshold. So you could easily convert &lt;br&gt;
this RGB image to grayscale and then binary B/W image. And &lt;br&gt;
then use bwlabel() and regionprops() followed by it..&lt;br&gt;
&lt;br&gt;
ex:&lt;br&gt;
RGB = imread('Your Image');&lt;br&gt;
gray = rgb2gray(RGB);&lt;br&gt;
bw = im2bw(gray, &amp;lt;computed threshold&amp;gt;);&lt;br&gt;
L = bwlabel(bw);&lt;br&gt;
stats = regionprops(L,'All');&lt;br&gt;
area = [stats.Area];&lt;br&gt;
&lt;br&gt;
HTH&lt;br&gt;
Vihang&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 21 Mar 2008 06:03:00 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422090</link>
      <author>Allen</author>
      <description>carlos wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; i think "regionprops" function is the solution to your&lt;br&gt;
&amp;gt; problem, in fact, with this function you can calculate a lot&lt;br&gt;
&amp;gt; more properties of your regions: area, centroid, perimeter,&lt;br&gt;
&amp;gt; euler number, etc.&lt;br&gt;
&amp;gt; the only condition is that you have first an segmented image&lt;br&gt;
&amp;gt; of course, but i think you have solved this.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&lt;br&gt;
Hi, Carlos!&lt;br&gt;
&lt;br&gt;
Ha!  Very interesting function!  I have some reading to do (that's a big &lt;br&gt;
function!).&lt;br&gt;
&lt;br&gt;
Thank you for your response and quick help!  I'll definitely post on &lt;br&gt;
here if I have any success.  :)&lt;br&gt;
&lt;br&gt;
My very best!&lt;br&gt;
-Allen&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 21 Mar 2008 05:30:04 -0400</pubDate>
      <title>Re: Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422086</link>
      <author>carlos </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
i think "regionprops" function is the solution to your&lt;br&gt;
problem, in fact, with this function you can calculate a lot&lt;br&gt;
more properties of your regions: area, centroid, perimeter,&lt;br&gt;
euler number, etc.&lt;br&gt;
the only condition is that you have first an segmented image&lt;br&gt;
of course, but i think you have solved this.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Allen &amp;lt;ajhalldeleteme@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;frvesa$ol9$1@news.ks.uiuc.edu&amp;gt;...&lt;br&gt;
&amp;gt; Hi guys,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Quick Q version:&lt;br&gt;
&amp;gt; 	How does one determine the fractional pixel area of a&lt;br&gt;
color.  i.e., if &lt;br&gt;
&amp;gt; I highlight grains one color, how can I determine the area&lt;br&gt;
of the &lt;br&gt;
&amp;gt; colored portion in pixels?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Longer Q version:&lt;br&gt;
&amp;gt; 	I'm doing something complex (finding the surface area of&lt;br&gt;
a tilted &lt;br&gt;
&amp;gt; segment of an image)... but I think it can be done very&lt;br&gt;
simply.&lt;br&gt;
&amp;gt; 	I have a method to highlight only the area of interest,&lt;br&gt;
and now I want &lt;br&gt;
&amp;gt; to determine the area which is highlighted.  I'm assuming&lt;br&gt;
this will be &lt;br&gt;
&amp;gt; in pixels x pixels of the image, but can convert this&lt;br&gt;
easily to &lt;br&gt;
&amp;gt; real-space (as well as use the cosine of the tilt to give&lt;br&gt;
me the real area).&lt;br&gt;
&amp;gt; 	So, is there a good way to get image information about areas &lt;br&gt;
&amp;gt; highlighted with specific colors etc.?  If I painted one&lt;br&gt;
section of the &lt;br&gt;
&amp;gt; image all red, for instance, could I determine the pixel x&lt;br&gt;
pixel area?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks a ton for your help and thoughts, everyone!!  :)&lt;br&gt;
&amp;gt; -Allen&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ps- this is an attempt to measure the surface-area of&lt;br&gt;
facets in a grown &lt;br&gt;
&amp;gt; crystal.  The data is taken from an AFM, and I can&lt;br&gt;
highlight them based &lt;br&gt;
&amp;gt; on the surface-gradient information.  The resulting images&lt;br&gt;
in plan-view &lt;br&gt;
&amp;gt; will be flat (forshortened areas etc.)&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 21 Mar 2008 04:51:21 -0400</pubDate>
      <title>Area of specific pixel color?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166108#422081</link>
      <author>Allen</author>
      <description>Hi guys,&lt;br&gt;
&lt;br&gt;
Quick Q version:&lt;br&gt;
	How does one determine the fractional pixel area of a color.  i.e., if &lt;br&gt;
I highlight grains one color, how can I determine the area of the &lt;br&gt;
colored portion in pixels?&lt;br&gt;
&lt;br&gt;
Longer Q version:&lt;br&gt;
	I'm doing something complex (finding the surface area of a tilted &lt;br&gt;
segment of an image)... but I think it can be done very simply.&lt;br&gt;
	I have a method to highlight only the area of interest, and now I want &lt;br&gt;
to determine the area which is highlighted.  I'm assuming this will be &lt;br&gt;
in pixels x pixels of the image, but can convert this easily to &lt;br&gt;
real-space (as well as use the cosine of the tilt to give me the real area).&lt;br&gt;
	So, is there a good way to get image information about areas &lt;br&gt;
highlighted with specific colors etc.?  If I painted one section of the &lt;br&gt;
image all red, for instance, could I determine the pixel x pixel area?&lt;br&gt;
&lt;br&gt;
Thanks a ton for your help and thoughts, everyone!!  :)&lt;br&gt;
-Allen&lt;br&gt;
&lt;br&gt;
ps- this is an attempt to measure the surface-area of facets in a grown &lt;br&gt;
crystal.  The data is taken from an AFM, and I can highlight them based &lt;br&gt;
on the surface-gradient information.  The resulting images in plan-view &lt;br&gt;
will be flat (forshortened areas etc.)&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
