Mask() algorithm
in
Programming Questions
•
3 years ago
I want to know what is the algorithm behind Processing's mask() function
I have used this and it is kinda similar but not perfect yet
- void mask2(PImage a1,PImage a2){
for (int x=0;x<a1.pixels.length-1;x++){
color c2 = a2.pixels[x];
a1.pixels[x]=color(red(c2),green(c2),blue(c2),blue(c2));
}
}
The processing wiki says the following
Description
Masks part of an image from displaying by loading another image and using it as an alpha channel. This mask image should only contain grayscale data, but only the blue color channel is used. The mask image needs to be the same size as the image to which it is applied.
In addition to using a mask image, an integer array containing the alpha channel data can be specified directly. This method is useful for creating dynamically generated alpha masks. This array must be of the same length as the target image's pixels array and should contain only grayscale data of values between 0-255.
1