problem with using Gabor filter to segment floor

2 visualizaciones (últimos 30 días)
hajer jon
hajer jon el 28 de Jul. de 2019
Comentada: Image Analyst el 20 de Feb. de 2021
hi
i excute this code to get floor from image but not all floor.
Agray = rgb2gray(I);Untitled.png
imageSize = size(I);
numRows = imageSize(1);
numCols = imageSize(2);
wavelengthMin = 4/sqrt(2);
wavelengthMax = hypot(numRows,numCols);
n = floor(log2(wavelengthMax/wavelengthMin));
wavelength = 2.^(0:(n-2)) * wavelengthMin;
deltaTheta = 45;%%good result if reduce no
orientation = 0:deltaTheta:(180-deltaTheta);
g = gabor(wavelength,orientation);
gabormag = imgaborfilt(Agray,g);
for i = 1:length(g)
sigma = 0.5*g(i).Wavelength;%%good result if reduse no
K = 3;
gabormag(:,:,i) = imgaussfilt(gabormag(:,:,i),K*sigma);
end
X = 1:numCols;
Y = 1:numRows;
[X,Y] = meshgrid(X,Y);
featureSet = cat(3,gabormag,X);
featureSet = cat(3,featureSet,Y);
numPoints = numRows*numCols;
X = reshape(featureSet,numRows*numCols,[]);
X = bsxfun(@minus, X, mean(X));
X = bsxfun(@rdivide,X,std(X));
coeff = pca(X);
feature2DImage = reshape(X*coeff(:,1),numRows,numCols);
Lg = kmeans(X,2,'Replicates',5);
Lg = reshape(Lg,[numRows numCols]);
Aseg1 = zeros(size(I),'like',I);
Aseg2 = zeros(size(I),'like',I);
BWg = Lg == 2;
BWg = repmat(BWg,[1 1 3]);
Aseg1(BWg) = I(BWg);
Aseg2(~BWg) = I(~BWg);
  6 comentarios
mustafa khalil
mustafa khalil el 20 de Feb. de 2021
A = imread('kobi.png'); A = imresize(A,0.25); Agray = rgb2gray(A); figure imshow(A); imageSize = size(A); numRows = imageSize(1); numCols = imageSize(2);
wavelengthMin = 4/sqrt(2); wavelengthMax = hypot(numRows,numCols); n = floor(log2(wavelengthMax/wavelengthMin)); wavelength = 2.^(0:(n-2)) * wavelengthMin;
deltaTheta = 45; orientation = 0:deltaTheta:(180-deltaTheta);
g = gabor(wavelength,orientation); gabormag = imgaborfilt(Agray,g); for i = 1:length(g) sigma = 0.5*g(i).Wavelength; K = 3; gabormag(:,:,i) = imgaussfilt(gabormag(:,:,i),K*sigma); end X = 1:numCols; Y = 1:numRows; [X,Y] = meshgrid(X,Y); featureSet = cat(3,gabormag,X); featureSet = cat(3,featureSet,Y); numPoints = numRows*numCols; X = reshape(featureSet,numRows*numCols,[]);
X = bsxfun(@minus, X, mean(X)); X = bsxfun(@rdivide,X,std(X)); coeff = pca(X); feature2DImage = reshape(X*coeff(:,1),numRows,numCols); figure imshow(feature2DImage,[]); L = kmeans(X,2,'Replicates',5); L = reshape(L,[numRows numCols]); figure imshow(label2rgb(L)); Aseg1 = zeros(size(A),'like',A); Aseg2 = zeros(size(A),'like',A); BW = L == 2; BW = repmat(BW,[1 1 3]); Aseg1(BW) = A(BW); Aseg2(~BW) = A(~BW); figure imshowpair(Aseg1,Aseg2,'montage');
Please please help when implementing more than once the output is an edge instead of the cut-off part
Image Analyst
Image Analyst el 20 de Feb. de 2021
@hajer jon has not been seen here in a year and a half so I doubt he will help you.

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 5 de Ag. de 2019
It looks like a frame from a video. Assuming the humans are moving, it's probably best to either get a snapshot when no one is on the floor, or if you can't get that, then take multiple frames spaced minutes apart and use the mode. The mode will assume that the floor color is the most common color at that position since people are not on it more than they are not on it.
  4 comentarios
hajer jon
hajer jon el 5 de Ag. de 2019
How can i use mod ?
Image Analyst
Image Analyst el 6 de Ag. de 2019
Save up a bunch of frames for training, then take a histogram of each pixel getting the mode value (or use the mode() function, if there is one). Then create an image where each pixel is the mode.

Iniciar sesión para comentar.


Shashank Gupta
Shashank Gupta el 2 de Ag. de 2019
I understand that you want to segment out some texture from the image which is floor in your case. Gabor filters are traditional approach for unsupervised segmentation still they offer the best simultaneous localization of spatial and frequency information. However, it has some limitations, maximum bandwidth offer by Gabor filter is limited, so one seeking broad spectral information with maximum spatial localization is not optimal. I suggest you check the spectrum of image first and see does it satisfy the Bandwidth limitation and try changing the hyperparameter which are involved in Gabor filter. You can also try changing the number of Cluster in K-means which give more flexibility to handle the frequency distribution.
  1 comentario
hajer jon
hajer jon el 4 de Ag. de 2019
thank you somuch for answer
I traied change kmean value and segma that make good results but it change when repeat run for code!!
about spectrum how can check the spectrum in matlab?use fft2() ?it gave me very big array 1080x1920x3 complex double how can help me in slution ??

Iniciar sesión para comentar.

Categorías

Más información sobre 3-D Volumetric Image Processing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by