edit -door detection
古いコメントを表示
I have a code for detecting the door,but id detect only some images ,it detects only doors brown in colour,if it is other colours,it os not detecting,please help
clc
clear all
[filename, pathname] = ...
uigetfile({'*.jpg';'*.bmp';'*.png';'*.*'},'File Selector');
i=imread([pathname,filename]);
I=i;
if length(size(i)) == 3
im = double(i(:,:,2));
else
im = double(i);
end
cs = fast_corner_detect_9(im, 60)
size(im)
image(im/6)
axis image
colormap(gray)
hold on
axis off
plot(cs(:,1), cs(:,2), 'r.'),title('Corner Detection')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%GUASSIAN SMOOTHING %%%%%%%%%%%%%%%%%%%%%%%%%%%%
G = fspecial('gaussian',[5 5],2);
Ig = imfilter(im,G,'same');
figure('name','Guassian Smoothing','numbertitle','off'),imshow(uint8(Ig))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%RESIZING AN IMAGE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I1=imresize(Ig,.5)
figure('name','Reduced Resolution Image','numbertitle','off'),imshow(uint8(I1))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%EDGE DETECTION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
edge_detect=edge(im,'sobel');
figure('name','Edge detected Image','numbertitle','off'),imshow(edge_detect);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%DETCTION%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cform = makecform('srgb2lab');
J = applycform(I,cform);
%figure;imshow(J);
K=J(:,:,2);
%figure;imshow(K);
L=graythresh(J(:,:,2));
BW1=im2bw(J(:,:,2),L);
%figure;imshow(BW1);
M=graythresh(J(:,:,3));
%figure;imshow(J(:,:,3));
BW2=im2bw(J(:,:,3),M);
%figure;imshow(BW2);
O=BW1.*BW2;
% Bounding box
P=bwlabel(O,8);
BB=regionprops(P,'Boundingbox');
BB1=struct2cell(BB);
BB2=cell2mat(BB1);
[s1 s2]=size(BB2);
mx=0;
for k=3:4:s2-1
p=BB2(1,k)*BB2(1,k+1);
if p>mx & (BB2(1,k)/BB2(1,k+1))<1.8
mx=p;
j=k;
end
end
figure,imshow(I);
hold on;
rectangle('Position',[BB2(1,j-2),BB2(1,j-1),BB2(1,j),BB2(1,j+1)],'EdgeColor','g' )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%END OF CODING%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 件のコメント
Walter Roberson
2012 年 2 月 23 日
Duplicate is at http://www.mathworks.com/matlabcentral/answers/28416-reducing-the-size-of-image
Another branch of the same duplicate is at http://www.mathworks.com/matlabcentral/answers/26731-detecting-the-corners
kash
2012 年 2 月 23 日
kash
2012 年 2 月 23 日
Pria Bertopeng
2016 年 11 月 27 日
warning: the 'makecform' function belongs to the image package from Octave Forge but has not yet been implemented.
Please read http://www.octave.org/missing.html to learn how you can contribute missing functionality. error: 'makecform' undefined near line 42 column 9 error: called from doordetection at line 42 column 7
how to fix that?
thx
Walter Roberson
2016 年 11 月 27 日
Pria Bertopeng:
The obvious fix is to use MATLAB instead of Octave.
Questions specific to Octave should be addressed to an Octave resource.
Pria Bertopeng
2016 年 12 月 8 日
Can someone explain how this code works? especially on detection section. Thx
Walter Roberson
2016 年 12 月 8 日
It converts to L*a*b color space, and does a thresholding on the L (brightness) channel to produce a binary image in which 0 corresponds to darker spots and 1 corresponds to brighter spots.
You could also do much the same with rgb2gray, or with rgb2hsv and taking the v channel as the brightness.
回答 (3 件)
Winnie
2012 年 6 月 24 日
0 投票
hi...Did you write this code by yourself? Because my friend has the exact same code as you!
Image Analyst
2012 年 6 月 24 日
0 投票
I have no idea how challenging this is. Perhaps you have images with doors that have a known and contrasting color from the rest of the items in the image. If so, then you could use the color detection methods in my File Exchange and then check on what their area is (large = closed door, small = open door). http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 This would be one of the easier cases.
If you're hoping for some code that will tell you "open" or "closed" for every possible door that a search of "door" images on Google might bring up, then that's way beyond your capabilities now. Some people in the "CBIR" community are working on that but it's very very challenging. For example, show me, based on only the image pixels and no metadata, images that have pictures of babies in them. Or dogs, or doors, or cars, or whatever. Look up CBIR in a web search.
3 件のコメント
Walter Roberson
2012 年 6 月 24 日
For example there are a lot of windows that are also doors.
Image Analyst
2012 年 6 月 24 日
Not to mention things like gates. Is a half height solid wooden gate a door? How about a full height, wrought iron, non-solid gate? Is it supposed to find the door on a car, and the door to the batteries on my electronic device, as well as doors to buildings? What if the door is glass, like in many modern buildings? I wouldn't tackle this problem unless it was very very constrained to certain types of doors.
Walter Roberson
2012 年 6 月 24 日
Yes for the solid wooden gates: consider the traditional "Old West" saloon doors.
Tanim Ahsan
2017 年 2 月 23 日
0 投票
@kash Did u able to solve your problem?
カテゴリ
ヘルプ センター および File Exchange で L*a*b* Color Space についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!