数字图像处理特效中彩色墨水效果的设计与实现
先來看兩張對比圖,首先是原圖。
下面是處理后的效果,其實下圖看起來已經不再像是一張拍攝的照片了,更像是手工繪制的。
其實除了對于邊緣的描繪外,顯然對色彩也需要進行適當處理。
應該還可以有改進的空間,但是畢竟算法的實現方式非常的簡單,而且畢竟體現了處理此類問題所應該考慮的基本思想。
下面是我基于MAGICHOUSE平臺用C++實現的代碼。
函數調用部分
SeaFun::InkSketch(our_image_buffer,temp_imageBuffer,X_image,Y_image);
for(int n=0; n<sum; n+=4)
{
?? ??? ?temp_imageBuffer[n] = temp_imageBuffer[n]>0 ? our_image_buffer[n]:temp_imageBuffer[n];
?? ??? ?temp_imageBuffer[n+1] = temp_imageBuffer[n+1]>0 ? our_image_buffer[n+1]:temp_imageBuffer[n+1];
?? ??? ?temp_imageBuffer[n+2] = temp_imageBuffer[n+2]>0 ? our_image_buffer[n+2]:temp_imageBuffer[n+2];
}
實現部分
??? static void InkSketch(BYTE* image0, BYTE* image1, unsigned int w, unsigned int h)
?? ?{
?? ??? ?BYTE** imageBuf0 = CreatImage(image0, w, h);
?? ??? ?BYTE** imageBuf1 = CreatImage(image1, w, h);
?? ??? ?double scale=2;
?? ??? ?int templt[25]={
?? ??? ??? ? -1,? -1,? -1,? -1, -1,?
???????????? -1,? -1,? -1,? -1, -1,?
???????????? -1,? -1,? 30,? -1, -1,?
???????????? -1,? -1,? -1,? -1, -1,?
???????????? -1,? -1,? -5,? -1, -1
?? ??? ?};
?? ??? ?int x,y;
?? ??? ?int a;
?? ??? ?
?? ??? ?for(y=2; y<h-2; y++)
?? ??? ?for(x=2; x<w-2; x++)
?? ??? ?{
?? ??? ??? ?a=TempltExcute(imageBuf0,w,h,templt,5,x,y);
?? ??? ??? ?a*= scale;
?? ??? ??? ?a = a>255?255:a;?? ?
?? ??? ??? ?a = a<0?0:a;
?? ??? ??? ?SetPixel2(imageBuf1,x,y,a);
?? ??? ?}
?? ??? ?free(imageBuf0);
?? ??? ?free(imageBuf1);
?? ?}
總結
以上是生活随笔為你收集整理的数字图像处理特效中彩色墨水效果的设计与实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 利用小波融合对由聚焦失败导致的图像模糊进
- 下一篇: 图像处理中常用数学知识