Skip to content

Image Enhancement Spatial Domain

Aim:- Image Enhancement Spatial Domain
MSc Computer Science Image Processing Practical No. 8
Index of all Practicals ~ Click Here

Code:- Edge_detection.m

clc;clear all;close all;
I = imread(‘rice.png’);
background = imopen(I,strel(‘disk’,15)); 
%strel->Create morphological structuring element.

I2 = imsubtract(I,background);
I3 = imadjust(I2, stretchlim(I2), [0 1]); 
%stretchlim->Find limits to contrast stretch an image.

level = graythresh(I3);                  
%GRAYTHRESH->Compute global image threshold

BW1 = im2bw(I3,level);                   
%IM2BW ->Convert to binary image by thresholding.

[labeled,numObjects] = bwlabel(BW1,4); 
%BWLABEL–> Label connected components in binary image.

numObjects
RGB_label = label2rgb(labeled, @spring, ‘c’, ‘shuffle’);
% LABEL2RGB –> converts label matrix to RGB image.

figure, imshow(RGB_label);
graindata = regionprops(labeled,’basic’); 
% REGIONPROPS –> Measure properties of image regions.
allgrains = [graindata.Area];
figure, hist(allgrains,numObjects);

Output:-
On Command Window:-

numObjects =
   101

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!