problem with using Gabor filter to segment floor
2 次查看(过去 30 天)
显示 更早的评论
hi
i excute this code to get floor from image but not all floor.
Agray = rgb2gray(I);![Untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/231644/Untitled.png)
![Untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/231644/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 个评论
mustafa khalil
2021-2-20
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
2021-2-20
@hajer jon has not been seen here in a year and a half so I doubt he will help you.
回答(2 个)
Image Analyst
2019-8-5
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 个评论
Image Analyst
2019-8-6
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.
Shashank Gupta
2019-8-2
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!