Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!p25g2000hsf.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Area of specific pixel color?
Date: Fri, 21 Mar 2008 10:46:09 -0700 (PDT)
Organization: http://groups.google.com
Lines: 57
Message-ID: <005dc974-d030-4d5b-86f9-934e02fed496@p25g2000hsf.googlegroups.com>
References: <frvesa$ol9$1@news.ks.uiuc.edu>
NNTP-Posting-Host: 75.186.67.199
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1206121569 16499 127.0.0.1 (21 Mar 2008 17:46:09 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 21 Mar 2008 17:46:09 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: p25g2000hsf.googlegroups.com; posting-host=75.186.67.199; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 
Xref: news.mathworks.com comp.soft-sys.matlab:458512


On Mar 21, 12:51=A0am, Allen <ajhalldelet...@gmail.com> wrote:
> Hi guys,
>
> Quick Q version:
> =A0 =A0 =A0 =A0 How does one determine the fractional pixel area of a colo=
r. =A0i.e., if
> I highlight grains one color, how can I determine the area of the
> colored portion in pixels?
>
> Longer Q version:
> =A0 =A0 =A0 =A0 I'm doing something complex (finding the surface area of a=
 tilted
> segment of an image)... but I think it can be done very simply.
> =A0 =A0 =A0 =A0 I have a method to highlight only the area of interest, an=
d now I want
> to determine the area which is highlighted. =A0I'm assuming this will be
> in pixels x pixels of the image, but can convert this easily to
> real-space (as well as use the cosine of the tilt to give me the real area=
).
> =A0 =A0 =A0 =A0 So, is there a good way to get image information about are=
as
> highlighted with specific colors etc.? =A0If I painted one section of the
> image all red, for instance, could I determine the pixel x pixel area?
>
> Thanks a ton for your help and thoughts, everyone!! =A0:)
> -Allen
>
> ps- this is an attempt to measure the surface-area of facets in a grown
> crystal. =A0The data is taken from an AFM, and I can highlight them based
> on the surface-gradient information. =A0The resulting images in plan-view
> will be flat (forshortened areas etc.)

---------------------------------------------------------------------
Allen:
Rather than manually paint the image you cold also try the roipoly
function,  This will let you outline an area.  Then convert the area
to a binary image and call bwlabel and then regionprops.

Alternatively you could paint a color on the image (maybe by making a
modification to freehanddraw macro on the user file exchange), and
then threshold each color band, something like
paintcolor =3D [1 1 1];
paintedRegion =3D imageArray(:,:,1) =3D=3D paintcolor(1) && imageArray(:,:,
2) =3D=3D paintcolor(2) && imageArray(:,:,3) =3D=3D paintcolor(3)
areaOfPaintedRegion =3D sum(sum(paintedRegion));
That's the area of the projected region.  If it's tilted away from the
screen by an angle theta, then to get then you need to divide by the
cosine of the angle to get the actual area as if it weren't tilted.
actualArea =3D areaOfPaintedRegion / cos(theta)
and if the angle is not a single angle, but a more general tilt, it
gets more complicated.

You might have to take care about whether the image and/or the paint
color is to be normalized to the 0-1 range or if it can stay in the
0-255 range - that's always a watchout in MATLAB.
Regards,
ImageAnalyst