This program displays following details for a given image
1. Jet Colormap Image
2. Background Estimation
3. Flattened Background Removal
4. Image Thresholding
5. Connected Region
6. Size Distribution Graph
7. Statistical
Measurement
Source
Code:
clc;
clear
all;
close
all;
inputImg
= imread('rice.png');
subplot(2,3,1);
imshow(inputImg);
title('Original
Image');
subplot(2,3,2)
imshow(inputImg);
colormap(Jet);
% Sets the current figures map to JET
title('Jet
Colormap Image');
%
Background Estimation
%
imopen performs morphological opening on the grayscale or binary image
%
strel is used to creat disk shaped structuring element of radius 10
ImageBackground
= imopen(inputImg,strel('disk',10));
subplot(2,3,3);
imshow(ImageBackground);
colormap(Jet);
title('Background
Estimation');
%
Background Removal
subImg
= imsubtract(inputImg,ImageBackground);
subplot(2,3,4);
imshow(subImg);
title('Flattened
Background Removal');
%
Segment Grains from the background, obtains the binary Image
%
graythresh computes Global Image Threshold
subplot(2,3,5);
binaryImg
= im2bw(subImg,graythresh(subImg));
imshow(binaryImg);
title('Thrsholded
Image');
%
Label Connected Region
[L
NUM] = bwlabel(binaryImg);
subplot(2,3,6);
imshow(L,[]);
colormap(jet);
pixval('on');
% Display information about image pixels.
title('Connected
Region');
%
Feature Extraction
%
Measures a set of properties for each labeled region in the label matrix L.
stats
= regionprops(L);
A
= [stats.Area];
figure;
hist(A);
xlabel('Area
in Pixels');
ylabel('Popularity');
title('Size
Distribution');
%
Statistical Measurement
mean(A);
std(A);
median(A);
0 comments:
Confused? Feel free to ask
Post a Comment