RE: How to get the image mask path
RE: How to get the image mask path
- Subject: RE: How to get the image mask path
- From: Vinay Prabhu <email@hidden>
- Date: Fri, 21 Jul 2006 18:00:08 +0530
- Importance: Normal
This sounds like a tough task!
Is there any API to extract the mask image from the 32 bit image?
-----Original Message-----
From: Uli Kusterer [mailto:email@hidden]
Sent: Friday, July 21, 2006 5:03 PM
To: Vinay Prabhu
Cc: 'Andrew Farmer'; email@hidden
Subject: Re: How to get the image mask path
Am 21.07.2006 um 11:06 schrieb Vinay Prabhu:
> If the image has only one masked area, is it possible to get the path?
>
> I don't know how to achieve this on Mac,
> but on windows it is possible.
> Please have a look at the attached image.
Well, one very simplistic approach you could take would be to first
detect the outline of the image, e.g. by going over each of the rows
of the image and recording it as ranges of starting and ending
coordinates. A starting coordinate is where a transparent (or white,
or whatever your background is) pixel is followed by an opaque pixel.
Ending coordinate would be where an opaque pixel is followed by a
transparent one. You'd do that for horizontal pixels (i.e. "inside
the row") as for vertical pixels ("between" the rows).
You'd have a very crude polygon-ish approximation of your image.
Now you'd have to somehow group together adjacent pixels into shapes,
so you have the "holes" and the outline as separate shapes. Finally,
you'd take three pixels each following the other and see whether you
can smooth them by e.g. turning them into two pixels with a curve
between them that goes through the third, or if they're exactly on
one line, or if they express a right angle, you'd turn them into line
segments instead.
That should smooth out the curves a little. Once you have all these
coordinates collected, building an NSBezierPath from them should be
trivial.
But as I said, that would be a very simplistic and crude approach,
and I'm not sure it's easy to to actually detect the shapes of
adjacent pixels.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s)and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender or email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden