Digital image processing using Matlab -...

22
Digital image processing using Matlab Seung Ho Kim [email protected] 051-510-3921 010-2107-9925 기계관 3301호

Transcript of Digital image processing using Matlab -...

Digital image processingusing Matlab

Seung Ho Kim

[email protected]

051-510-3921

010-2107-9925

기계관 3301호

Digital image processing

• 디지털 화상처리 또는 디지털 영상 처리는 컴퓨터 알고리즘을 사용하여

디지털 이미지에 대한 화상처리를 수행하는 것이다. 디지털 신호처리의 하

위분야로, 디지털 영상처리는 아날로그 영상처리에 비해 많은 장점이 있다.

입력자료에 더욱 광범위한 알고리즘을 적용 가능하게 되고, 처리 도중 발

생하는 잡음과 신호 왜곡과 같은 문제들을 방지할 수 있다.

• 디지털 영상 처리는 영상 처리를 위한 훨씬 더 복잡한 알고리즘 사용을 가

능하게 하므로, 단순작업에 더욱 정교한 성능과 아날로그 수단으로는 불가

능한 방법의 실행, 양쪽을 가능하게 한다.

Digital image

• Color images : 24 bit

• Medical images : 16 bit

1 9 2 3

2 4 8 5

1 2 4 6

3 8 7 1

ImageJ

• http://imagej.nih.gov/ij/

• Google -> ImageJ 검색

Dicom

• Open ImageJ…• Image-Show info

Window/level

• Image-Adjust-…Brightness/Contrast

Matlab

Matlab

• For : for-end is a repetition statement providing a loop for automatic iteration over a range of numbers or objects.

• Ex 1) 𝑖=110 𝑖

sum = 0;for i = 1:1:10

sum = sum + i;end

Matlab

• Ex 2) sum(1:10), odd number

Sum = 0;

for i=1:1:10

if mod(i,2)==1

Sum = Sum+i;

end

end

Matlab - function

Function Definition Input variable

Imread Read a image filename, format

Imwrite Write a image as a file image, filename

Imshow Display image image, display range

imagesc Display image object image

Matlab – image I/O

• Use ‘imread’ (‘dicomread’)

• Img = imread(‘TestImg.jpg’);

• ImgBw = sum(double(Img),3)/3;

• imwrite(ImgBw , ’TestImgBw.jpg’);

Matlab – image filter

• Convolution – use ‘imfilter(A,h)’

* =

Matlab – image filter

• img = imread('peppers.png');

• h = fspecial('gaussian', 30, 5);

• imgFilt = imfilter(img , h , 'replicate');

• figure, imshow(imgFilt, [])

Matlab – image filter

• High-pass filtering

-1 0 1

-2 0 2

-1 0 1

1 2 1

0 0 0

-1 -2 -1

-1 -1 -1

-1 8 -1

-1 -1 -1

-1 0 1

-1 0 1

-1 0 1

Sobel Laplacian Prewitt

h = [-1 0 1; -2 0 2; -1 0 1];

Frequency domain filter

• Use ‘fft2’, ‘fftshift’, ‘ifft2’

fft2 fftshift

ifft2 fftshift

Frequency domain filter

fft2 & fftshift

×

fftshift & ifft2

Frequency domain filter

• img = imread('lena.jpg');

• img2 = sum(double(img),3);

•F = fftshift(fft2(img2));

• [M N] = size(img);

• sig = 10;

•H = fspecial('gaussian', M, sig);

•G = H.×F;

•g = ifft2(fftshift(G));

Gamma transform

0.5

1

1.5

𝛾=𝛾=1.5 𝛾=1 𝛾=0.5

• img = double(dicomread(‘Chest.dcm'));• f = img/max(img(:));• g = (f.^1.5)

Histogram equalization

Histogram = zeros(max(max(Img)),1);

for i=1:size(Img,1)

for j=1:size(Img,2)

Histogram(Img(i,j)) = Histogram(Img(i,j))+1;

end

end

for i=1:numel(Histogram);

CumSum(i) = sum(Histogram(1:i));

end

ni = CumSum/size(Img,1)/size(Img,2)*max(max(Img));

Img2 = zeros(size(Img));

for i=1:size(Img,1)

for j=1:size(Img,2)

Img2(i,j) = round(ni(Img(i,j)))+1;

end

end

Unsharp masking

• 𝐼′ = 1 + 𝛼 𝐼 − 𝛼𝑔 ∗ 𝐼

Unsharp masking

•dcm = dicomread('ChestDR.dcm');• h = fspecial('gaussian', 30, 5);• imgBlur = imfilter(img, h);• imgUnsharp = img*1.5-0.5*imgBlur;