Azzera filtri
Azzera filtri

Image Segmentation using their magnitude and direction gradients

5 visualizzazioni (ultimi 30 giorni)
Hello all, i have attacthed magnitude and direction gradients of 3 images. I am trying to achieve a segmentation where the section below the red curve is removed and the section above the red curve should be preserved. I have shown below for image 2:
I have attatched what i want to acheive for image 1 and image 3 as Image-1 and image-3. I used paint to highlight the red curve. Can you guys suggest me some ways to acheive this? Any help is appreciated and thankyou in advance. The code i used is below
clc;
clear;
close all;
a=imread(filename);
B = imgaussfilt(a,1.4);
[Gmag,Gdir]=imgradient(B,'prewitt');
figure;
imshowpair(Gmag,Gdir,'montage');
I have also attacthed the original images as org1, org2 and org3.

Risposte (1)

Image Analyst
Image Analyst il 7 Giu 2020
Just threshold the image and use find() to find the last row in each column where the signal is above the threshold.
thresholdValue = 10; % Whatever works
[rows, columns, numberOfColorChannels] = size(grayImage);
lastRows = zeros(1, columns);
for col = 1 : columns
r = find(grayImage(:, col) > threshold, 1, 'last')
if ~isempty(r)
lastRows(col) = r;
end
end
  1 Commento
Apoorva Maiya
Apoorva Maiya il 9 Giu 2020
Thank you for your help but this methos doesnt seem to work since some rows are empty. Is there anything we could do with the direction gradient because it shows a sharp ridge at whare I want to segment the image.

Accedi per commentare.

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by