%********************************Task 1***********************************
% For a 8-bit gray image (lena.bmp)
% Use a dithering matrix (4*4), generate the dithered image.
%*************************************************************************
%function defined
function []=dither1()
%import the 8-bit gray image (lena.bmp)
I=imread('image/lena.bmp');
[I_length,I_width]=size(I);
%Define the 4*4 matrix
D = [0,8,2,10; 12,4,14,6; 3,11,1,9; 15,7,13,5];
%Output matrix
O=zeros(4*I_length,4*I_width);
%Map the image (0~255) to a new scope (0~16) and dither
divide=256/17;
tmp_I=I./(divide);
for x = 1:I_length
for y = 1:I_width
for p = 1:4
for q = 1:4
if tmp_I(x,y)>= D(p,q)
O(4 *(x-1) + p,4 *(y-1) + q) = 1;
else
O(4 *(x-1) + p,4 *(y-1) + q) = 0;
end
end
end
end
end
%show the result
subplot(121),imshow(I),title('8-bit gray lena.bmp');
subplot(122),imshow(O),title('dithered image');
本文来源:https://www.wddqw.com/doc/1bb6d2ec5bf5f61fb7360b4c2e3f5727a5e924d6.html
正在阅读:
Matlab实现对图像抖动算法01-01
木瓜泡米酒的功效有哪些01-01
七夕情人节礼物 七夕礼物推荐给特别情人01-01
坡鹿——琼岛精灵 阅读答案01-01
生命起源的科学研究01-01
整桶原味奶茶做法01-01
别人必赞的情感经典说说01-01
关于描写毕业季的句子01-01