# Demo entry 6677180

ʕʘ̅͜ʘ̅ʔ

Submitted by anonymous on Dec 03, 2017 at 06:11
Language: Matlab. Code size: 3.3 kB.

```clc;clear all;close all;
tic

%I1调整灰度范围

%I2调整gamma值

%I2直方图均衡化
g4 = histeq(I2,256);

%%%%%%%%%%%%%%%%%%%%%%步骤一：原图像直方图，分别用imhist和bar%%%%%%%%%%%%%%%%%%%
figure('name','原图像直方图，分别用imhist和bar')

subplot(4,1,1),imhist(I1),title('李锦州-病变乳房图像的直方图')

subplot(4,1,2)
h1 = imhist(I1);
h2 = h1(1:8:256);
horz = (1:8:256);
bar(horz,h2)
axis([0 255 0 15000])
title('李锦州-bar函数绘制的病变乳房图像直方图')

subplot(4,1,3),imhist(I2),ylim('auto'),title('李锦州-偏暗的花粉图像直方图')

subplot(4,1,4)
h3 = imhist(I2);
h4 = h3(1:4:256);
horz = (1:4:256);
bar(horz,h4)
axis([0 255 0 15000])
title('李锦州-bar函数绘制的偏暗的花粉图像直方图')
%%%%%%%%%%%%%%%%%%%%%%步骤二：偏暗花粉图像的伽马变换%%%%%%%%%%%%%%%%%%%%%%%%%%%%

figure('name','偏暗花粉图像的伽马变换')
subplot(2,2,1),imshow(I2),title('李锦州-原图像')
subplot(2,2,2),imshow(g1),title('李锦州-伽马为0.3图像')
subplot(2,2,3),imshow(g2),title('李锦州-伽马为1图像')
subplot(2,2,4),imshow(g3),title('李锦州-伽马为3原图像')

%%%%%%%%%%%%%%%%%%%%%%%%%步骤三偏暗花粉图像直方图均衡化%%%%%%%%%%%%%%%%%%%%%%%%
figure('name','偏暗花粉图像直方图均衡化')

subplot(2,2,1),imshow(I2),title('李锦州-原图像')
subplot(2,2,2),imhist(I2),title('李锦州-原图像直方图')
subplot(2,2,3),imshow(g4),title('李锦州-直方图均衡化图像')
subplot(2,2,4),imhist(g4),title('李锦州-均衡化图像直方图')
%%%%%%%%%%%%%%%%%%步骤四第一步：加噪电路板中值滤波%%%%%%%%%%%%%%%%%%%%%%%%%%%

Noise_01 = imnoise(I3,'salt & pepper',0.1);
Noise_02 = imnoise(I3,'salt & pepper',0.2);
Noise_03 = imnoise(I3,'salt & pepper',0.3);

g1 = medianFilter(Noise_01,3,3);
g2 = medianFilter(Noise_02,3,3);
g3 = medianFilter(Noise_03,3,3);

g4 = medfilt2(Noise_01,[3 3]);
g5 = medfilt2(Noise_02,[3 3]);
g6 = medfilt2(Noise_03,[3 3]);

% delta = g3 - g6;
% figure,imshow(delta);
figure('name','加噪电路板中值滤波')
subplot(4,2,1),imshow(I3),title('李锦州-原图像')
subplot(4,2,3),imshow(g1),title('李锦州-椒盐噪声强度为0.1并用自编函数滤波后图像')
subplot(4,2,4),imshow(g4),title('李锦州-椒盐噪声强度为0.1并用medfilt2函数滤波后图像')
subplot(4,2,5),imshow(g2),title('李锦州-椒盐噪声强度为0.2并用自编函数滤波后图像')
subplot(4,2,6),imshow(g5),title('李锦州-椒盐噪声强度为0.2并用medfilt2函数滤波后图像')
subplot(4,2,7),imshow(g3),title('李锦州-椒盐噪声强度为0.3并用自编函数滤波后图像')
subplot(4,2,8),imshow(g6),title('李锦州-椒盐噪声强度为0.3并用medfilt2函数滤波后图像')
%%%%%%%%%%%%%%%%%%%%步骤四第二步：加噪电路板中值滤波%%%%%%%%%%%%%%%%%%%%%%%%%%%
Noise_04 = imnoise(I3,'salt & pepper',0.4);

g7 = medianFilter(Noise_04,5,5);
g8 = medianFilter(Noise_04,7,7);
g9 = medianFilter(Noise_04,25,25);

g10 = medfilt2(Noise_04,[5 5]);
g11 = medfilt2(Noise_04,[7 7]);
g12 = medfilt2(Noise_04,[25 25]);

% delta1 = g7 - g12;
% figure,imshow(delta1);

figure('name','加噪图像中值滤波')
subplot(4,2,1),imshow(I3),title('李锦州-原图像')
subplot(4,2,2),imshow(Noise_04),title('李锦州-椒盐噪声强度为0.4加噪后图像')
subplot(4,2,3),imshow(g7),title('李锦州-用自编函数模版5*5滤波后图像')
subplot(4,2,4),imshow(g10),title('李锦州-用medfilt2函数模版5*5滤波后图像')
subplot(4,2,5),imshow(g8),title('李锦州-用自编函数模版7*7滤波后图像')
subplot(4,2,6),imshow(g11),title('李锦州-用medfilt2函数模版7*7滤波后图像')
subplot(4,2,7),imshow(g9),title('李锦州-用自编函数模版25*25滤波后图像')
subplot(4,2,8),imshow(g12),title('李锦州-用medfilt2函数模版25*25滤波后图像')
toc
```

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.