![]() Original |
![]() Covered in Snow |
We create a very high contrast grayscale version of the image, then generate an error diffusion scatter of white and black pixels by converting it to 1-bit, then back to 8-bit grayscale again. The black and white scatter picture is dropped over the original using a threshold of zero. This sets the black pixels to be transparent.
int artsnow(imgdes *srcimg, imgdes *resimg)
{
imgdes tmp24, tmp8, tmp1;
int cols, rows, rcode, mode=0;
cols = CALC_WIDTH(srcimg);
rows = CALC_HEIGHT(srcimg);
allocimage(&tmp8, cols, rows, 8);
allocimage(&tmp1, cols, rows, 1);
if(srcimg->bmh->biBitCount == 24) {
allocimage(&tmp24, cols, rows, 24);
}
colortogray(srcimg, &tmp8);
expandcontrast(100, 155, &tmp8, &tmp8);
convert8bitto1bit(mode, &tmp8, &tmp1);
convert1bitto8bit(&tmp1, &tmp8);
if(srcimg->bmh->biBitCount == 24) {
convertpaltorgb(&tmp8, &tmp24);
rcode = cover(0, srcimg, &tmp24, resimg);
freeimage(&tmp24);
}
else
rcode = cover(0, srcimg, &tmp8, resimg);
freeimage(&tmp1);
freeimage(&tmp8);
return(rcode);
}
Victor Image Processing Library homepage |
Victor Sample Code