http://archive.gamedev.net/archive/reference/programming/features/imageproc/page2.html
Algorithm 9 : Embossing effect filter
- Convert the image into grayscale
- For every pixel ( i , j ) on the output bitmap
- Compute its color using formula (R13)
- Set the pixel
#define emboss_w 3 #define emboss_h 3 sumr=0; sumg=0; sumb=0; int emboss_filter[emboss_w][emboss_h]={{2,0,0},{0,-1,0},{0,0,-1}}; int emboss_sum=1; for(i=1;i<temp->w-1;i++){ for(j=1;j<temp->h-1;j++){ color=getpixel(temp,i,j); r=getr32(color); g=getg32(color); b=getb32(color); h=(r+g+b)/3; if(h>255) h=255; if(h<0) h=0; putpixel(temp1,i,j,makecol(h,h,h)); } } for(i=1;i<temp->w-1;i++){ for(j=1;j<temp->h-1;j++){ sumr=0; for(k=0;k<emboss_w;k++){ for(l=0;l<emboss_h;l++){ color=getpixel(temp1,i-((emboss_w-1)>>1)+k,j-(( emboss_h-1)>>1)+l); r=getr32(color); sumr+=r*emboss_filter[k][l]; } } sumr/=emboss_sum; sumr+=128; if(sumr>255) sumr=255; if(sumr<0) sumr=0; putpixel(temp2,i,j,makecol(sumr,sumr,sumr)); } }
Here are the effects of this algorithm:
'Digital Image Processing' 카테고리의 다른 글
A simple C++ project for applying filters to raw images via command line. http://www.albertodebortoli.it (0) | 2017.03.13 |
---|---|
Using a Gray-Level Co-Occurrence Matrix (GLCM) (0) | 2017.02.03 |
Taking partial derivatives is easy in Matlab (0) | 2016.12.01 |
Matlab Image Processing (0) | 2016.12.01 |
Gabor Filter 이해하기 (0) | 2016.10.17 |