[Part 2] Basic Image Processing with Matlab
Monday, September 18, 2017
Easy steps to understand about the manual way to show grayscale image, black and white image, negative image. Let's see the explanation and the source code
Matlab Programming |
Lesson 2: Image Processing
Problems...
1) Make program to show grayscale image manually!
2) Make program to show black and white image manually!
3) Make program to show negative image manually!
Solutions...
%TAKE PICTURE FROM COMPUTER
I = imread ('E:\junris belajar\belajar imv\eded.png'); figure; imshow(I); title('Gambar Asli');
%GRAYSCALE IMAGE
p = uint8(0.2989 * double(I(:,:,1)) + 0.5870 * double(I(:,:,2)) + 0.1141 * double(I(:,:,3)));
figure; imshow(p); title('Grayscale'); %uint8 = unsigned integer 8 bit.
%BLACK AND WHITE IMAGE
[baris, kolom, layer] = size(I);
ambang = 70;
biner = zeros(baris, kolom, layer);
for j = 1 : layer
for k = 1 : baris
for l = 1 : kolom
if I(k,l,j) >= ambang
Biner(k,l,j) = 0;
else
Biner(k,l,j) = 1;
end
end
end
end
figure; imshow(Biner); title('hitam putih');
%NEGATIVE IMAGE
R = 255 - I; figure; imshow(R); title('negatif');
Happy Learning!