Matlab实现对图像抖动算法

2022-04-21 08:00:07   第一文档网     [ 字体: ] [ 阅读: ] [ 文档下载 ]
说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。下载word有问题请添加QQ:admin处理,感谢您的支持与谅解。点击这里给我发消息

#第一文档网# 导语】以下是®第一文档网的小编为您整理的《Matlab实现对图像抖动算法》,欢迎阅读!
抖动,算法,图像,实现,Matlab

%********************************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.dywdw.cn/1bb6d2ec5bf5f61fb7360b4c2e3f5727a5e924d6.html

相关推荐
推荐阅读