灰度图像划分比特平面matlab
f=imread('cman.tif');%读图[m,n]=size(f);img=zeros(m,n,8);%储存比特平面(二值图像)
for i=1:mfor j=1:np=dec2bin(f(i,j),8);%十进制灰度值转为二进制for k=1:length(p)if p(k)=='0'img(i,j,9-k)=0;elseimg(i,j,9-k)=1;endendend
endsubplot(241),imshow(img(:,:,8))
subplot(242),imshow(img(:,:,7))
subplot(243),imshow(img(:,:,6))
subplot(244),imshow(img(:,:,5))
subplot(245),imshow(img(:,:,4))
subplot(246),imshow(img(:,:,3))
subplot(247),imshow(img(:,:,2))
subplot(248),imshow(img(:,:,1))
结果如下:

依次是比特平面8到1,对应比特位数从左到右,位数越高,相应比特平面所含图像信息越多。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
