FROM : Vance
DATE : Wed Jan 30 19:27:07 2008
Yes that is a very good point that I should have mentioned. The images I
use are already pre-processes. So I don't have to worry about that. All
non-pure black is considered to be cloud information.
Here is a sample image:
http://aviationweather.gov/data/obs/sat/intl/ir_ICAO-A_bw.jpg (Lets
ignore the countries outline)
Thanks!
-Vance
Filipe Varela wrote:
> Yes but that raises a question which is whether you'll be replacing
> meaningful information based only on color. Your image may contain
> sections the same color as clouds which are not meant to be replaced.
>
> You may want to dig into pattern recognition, which is way off-topic.
>
> Cheers,
>
> Filipe
>
> On 2008/01/30, at 17:27, Vance wrote:
>
>> I want to replace the pure black as well as the black underneath the
>> areas of shaded white.
>>
>> The image I have contains satellite image of clouds. So replacing
>> only the pure black will not make it look right when placed on
>> background other then black.
>>
>> Does that mean I have to process even non-pure black regions myself
>> as well?
>>
>> Thanks!
>> Vance
>>
>> Filipe Varela wrote:
>>> If you only want to replace pure black, iterate thru every pixel in
>>> the bitmap looking for black (rgb channels same value = 0). Whenever
>>> you find such a pixel, change it's alpha value to whatever you need.
>>>
>>> ie
>>> unsigned char buffer = [rep bitmapData];
>>> unsigned char pixel; //temp
>>> for (h=0; h<height; h++) {
>>> for (w=0;w<width;w++) {
>>> pixel = buffer + (h * numBytesPerPixel * width) + w *
>>> numBytesPerPixel;
>>> //channel index depends on image format, check the attributes
>>> //attribs: (alpha first, alpha premultiplied, etc)
>>> //assume (example) that img is rgba. (0=red 1=green 2=blue
>>> 3=alpha)
>>> if(pixel[0]==0 && pixel[1]==0 && pixel[2]==0) // all black.
>>> set alpha to max
>>> pixel[3] = 255;
>>> }
>>> }
>>>
>>> Your image is now transparent or fully opaque.
>>>
>>> Cheers,
>>>
>>> Filipe
>>>
>>> On 2008/01/30, at 17:07, Vance wrote:
>>>
>>>> Hi,
>>>>
>>>> I have an NSImage (black and white) that I want to replace the
>>>> black color with transparency.
>>>>
>>>> I want it to be replaced in such a way, so even the shades of gray
>>>> look correct when overlayed on top of another color, lets say blue.
>>>>
>>>> What is the best way of do this?
>>>>
>>>> Thanks.
>>>> Vance
>>>> _______________________________________________
>>>>
>>>> Cocoa-dev mailing list (<email_removed>)
>>>>
>>>> Please do not post admin requests or moderator comments to the list.
>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>>
>>>> Help/Unsubscribe/Update your Subscription:
>>>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>>>
>>>> This email sent to <email_removed>
>>
DATE : Wed Jan 30 19:27:07 2008
Yes that is a very good point that I should have mentioned. The images I
use are already pre-processes. So I don't have to worry about that. All
non-pure black is considered to be cloud information.
Here is a sample image:
http://aviationweather.gov/data/obs/sat/intl/ir_ICAO-A_bw.jpg (Lets
ignore the countries outline)
Thanks!
-Vance
Filipe Varela wrote:
> Yes but that raises a question which is whether you'll be replacing
> meaningful information based only on color. Your image may contain
> sections the same color as clouds which are not meant to be replaced.
>
> You may want to dig into pattern recognition, which is way off-topic.
>
> Cheers,
>
> Filipe
>
> On 2008/01/30, at 17:27, Vance wrote:
>
>> I want to replace the pure black as well as the black underneath the
>> areas of shaded white.
>>
>> The image I have contains satellite image of clouds. So replacing
>> only the pure black will not make it look right when placed on
>> background other then black.
>>
>> Does that mean I have to process even non-pure black regions myself
>> as well?
>>
>> Thanks!
>> Vance
>>
>> Filipe Varela wrote:
>>> If you only want to replace pure black, iterate thru every pixel in
>>> the bitmap looking for black (rgb channels same value = 0). Whenever
>>> you find such a pixel, change it's alpha value to whatever you need.
>>>
>>> ie
>>> unsigned char buffer = [rep bitmapData];
>>> unsigned char pixel; //temp
>>> for (h=0; h<height; h++) {
>>> for (w=0;w<width;w++) {
>>> pixel = buffer + (h * numBytesPerPixel * width) + w *
>>> numBytesPerPixel;
>>> //channel index depends on image format, check the attributes
>>> //attribs: (alpha first, alpha premultiplied, etc)
>>> //assume (example) that img is rgba. (0=red 1=green 2=blue
>>> 3=alpha)
>>> if(pixel[0]==0 && pixel[1]==0 && pixel[2]==0) // all black.
>>> set alpha to max
>>> pixel[3] = 255;
>>> }
>>> }
>>>
>>> Your image is now transparent or fully opaque.
>>>
>>> Cheers,
>>>
>>> Filipe
>>>
>>> On 2008/01/30, at 17:07, Vance wrote:
>>>
>>>> Hi,
>>>>
>>>> I have an NSImage (black and white) that I want to replace the
>>>> black color with transparency.
>>>>
>>>> I want it to be replaced in such a way, so even the shades of gray
>>>> look correct when overlayed on top of another color, lets say blue.
>>>>
>>>> What is the best way of do this?
>>>>
>>>> Thanks.
>>>> Vance
>>>> _______________________________________________
>>>>
>>>> Cocoa-dev mailing list (<email_removed>)
>>>>
>>>> Please do not post admin requests or moderator comments to the list.
>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>>
>>>> Help/Unsubscribe/Update your Subscription:
>>>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>>>
>>>> This email sent to <email_removed>
>>
| Related mails | Author | Date |
|---|---|---|
| Vance | Jan 30, 18:07 | |
| Filipe Varela | Jan 30, 18:34 | |
| Vance | Jan 30, 19:27 | |
| douglas a. welton | Jan 30, 20:08 |






Cocoa mail archive

