36 lines
503 B
Mathematica
36 lines
503 B
Mathematica
|
|
clc;
|
||
|
|
close all ;
|
||
|
|
clear all ;
|
||
|
|
|
||
|
|
%% reading the image
|
||
|
|
l=13;
|
||
|
|
jpgFilename = strcat('e_images_',num2str(l), '.jpg');
|
||
|
|
rgb=imread(jpgFilename);
|
||
|
|
%% gray scaling
|
||
|
|
gray = rgb2gray(rgb);
|
||
|
|
figure(1);
|
||
|
|
imshow(gray);
|
||
|
|
title('gray scaled');
|
||
|
|
|
||
|
|
%% binary thresholding
|
||
|
|
|
||
|
|
[size1,size2]=size(gray);
|
||
|
|
for i=1:size1
|
||
|
|
for j=1:size2
|
||
|
|
if gray(i,j)<60
|
||
|
|
gray(i,j)=255;
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
BW=im2bw(gray,graythresh(gray));
|
||
|
|
|
||
|
|
figure(2);
|
||
|
|
imshow(BW);
|
||
|
|
|
||
|
|
%% hsv general
|
||
|
|
hsv = rgb2hsv(rgb);
|
||
|
|
figure(3);
|
||
|
|
imshow(hsv);
|
||
|
|
title('hsv')
|