1、光照不均的校正
例1:对光照不均图像的光照进行校正
BW=imread('rice.png');
subplot(221),imshow(BW),title('原始图像');
BW2=im2double(BW);
bg32=blkproc(BW2,[32 32],'min(x(:))'); %得到每个字块的极小值
bg256=imresize(bg32,[256 256],'bicubic'); %生成背景矩阵
subplot(222),imshow(bg256),title('背景灰度扩展结果');
d=BW2-bg256;
subplot(223),imshow(d),title('原始图像减去背景图像');
adjustbw=imadjust(d,[0 max(d(:))],[0,1],1);
subplot(224),imshow(adjustbw),title('最终处理结果');
效果图如下:
2、基于特征的逻辑运算
2.1基于特征的与运算
例2:找出图像dots和图像box相重合的对象
load imdemos dots box
subplot(121),imshow(box),title('box图像');
subplot(122),imshow(dots),title('dots图像');
原始图像如下:
logical_and=box&dots;
subplot(121),im