Clear Filters
Clear Filters

How to find region of interest using region props for multiple skin dermoscopic images

2 views (last 30 days)
I need to use region props to find region of interest in multiple skin lesion images. I am using Otsus segmentation method. Kindly help me use region props to find region of interest for multiple images. The lesion can be anywhere in the image thus the code should be able to identify which region has the lesion
.

Answers (1)

Image Analyst
Image Analyst on 3 Apr 2022
A full demo is given here in my Image Segmentation Tutorial:
Just convert your image to gray scale and it should work. In short
% Make sure the image is gray scale.
if ndims(rgbImage) == 3
% Is color. Need to convert it to gray scale.
grayImage = rgb2gray(rgbImage);
else
grayImage = rgbImage; % Was not really RGB after all.
end
% Binarize using Otsu's method to find the dark blob.
mask = imbinarize(grayImage);
% Take largest blob only.
mask = bwareafilt(mask, 1);
% Make measurements.
props = regionprops(mask, grayImage, 'Area', 'Perimeter', 'MeanIntensity'); % List whatever measurements you want.
area = props.Area
perimeter = props.Perimeter
meanGrayLevel = props.MeanIntensity
  2 Comments
Aashir Ahmed
Aashir Ahmed on 3 Apr 2022
%% Otsu Thresholding
close all;
clear all;
clc
%%================================================================================================
location = 'demo.jpg'; % folder in which your images exists
ds = imageDatastore(location) % Creates a datastore for all images in your folder
while hasdata(ds)
img = read(ds) ; % read image from datastore
figure, imshow(img); % creates a new window for each image
%%=================================================================================================
n=imhist(img); % Compute the histogram
N=sum(n); % sum the values of all the histogram values
max=0; %initialize maximum to zero
%%================================================================================================
for i=1:256
P(i)=n(i)/N; %Computing the probability of each intensity level
end
%%================================================================================================
for T=2:255 % step through all thresholds from 2 to 255
w0=sum(P(1:T)); % Probability of class 1 (separated by threshold)
w1=sum(P(T+1:256)); %probability of class2 (separated by threshold)
u0=dot([0:T-1],P(1:T))/w0; % class mean u0
u1=dot([T:255],P(T+1:256))/w1; % class mean u1
sigma=w0*w1*((u1-u0)^2); % compute sigma i.e variance(between class)
if sigma>max % compare sigma with maximum
max=sigma; % update the value of max i.e max=sigma
threshold=T-1; % desired threshold corresponds to maximum variance of between class
end
end
%%====================================================================================================
bw=im2bw(img,threshold/255); % Convert to Binary Image
bw= imclearborder(~bw);
figure ,imshow(bw); % Display the Binary Image
%%====================================================================================================
end
Aashir Ahmed
Aashir Ahmed on 3 Apr 2022
Heres my otsus code. I am still insure how will I be able to use region props to accurately find the region of lesion. I have used your code but it gives values. I just need some guidance on how will I use the values to get the region of the lesion. Thank you

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!