Author Topic: Help detect the end of the corridor of an image  (Read 1065 times)

Offline kambinatoR

  • Newbie
  • *
  • Posts: 2
    • View Profile
Help detect the end of the corridor of an image
« on: June 24, 2009, 09:48:06 AM »
Hi, I have an imaginary bot that walks on a corridor and takes pictures of the hall, have to make the bot to understand where is the end of the hall. Main.m is the main file.

I have a picture of the corridor. I used the edge function to detect the edges of the image of the corridor. I blurred the image to avoid noise. Used different edge functions (for comparison) and do not know if I put the correct formula for the Mean Square Error to compare them to show which is better. I have to compare the edge function's results between them, to show that edge_prewit is the cleanest and has the best result, i want to show this with MSE and with other different methods, for example luminance (luminosity).

Now I have to do the bot to understand where is the end of the corridor with other words to detect the square (the shape of the square with white outline).
After detecting the square I have to trace the lines from the corners of the square to make Matlab (or my imaginary bot) to see the whole corridor (not just the square).

I have attached all the files i use in program.zip, and now simply paste the codes here:

Quote
Main.m

originalRGB = imread('coridor1.jpg');

h = fspecial('gaussian',4,8); %blurr the image
I=imfilter(originalRGB,h);

figure(1), imshow(originalRGB), figure(2), imshow(I); %Show the blurred image
imwrite(I,'coridor3.jpg','jpg')
figure(3), I3=edgecolor_prewit('coridor3.jpg'), imshow(I3) %edge prewit
figure(4), I4=edgecolor('coridor3.jpg'), imshow(I4) %edge canny
figure(5), I5=edgecolor_sobel('coridor3.jpg'), imshow(I5) %edge sobel
%subplot(2,2,1), imshow(originalRGB);title('Original image');
%subplot(2,2,2), imshow(I); title('Blurred image');

% h = fspecial('gaussian',6,8);
% I4=imfilter(I3,h);
% figure(4), imshow(I4)

[m,n] = size('coridor1.jpg');
error = originalRGB-I3;
MSE = (sum(sum(error.*error)))/(m*n)

error2 = originalRGB-I4;
MSE2 = (sum(sum(error2.*error2)))/(m*n)

error3 = originalRGB-I5;
MSE3 = (sum(sum(error3.*error3)))/(m*n)



Quote
edgecolor.m
%Finding edges of a color image
%Usage edgecolor('female.jpg');


function S=edgecolor(nm);
img=imread(nm);
[x y z]=size(img);
if z==1
rslt=edge(img,'canny');
elseif z==3
img1=rgb2ycbcr(img);
dx1=edge(img1(:,:,1),'canny');
dx1=(dx1*255);
img2(:,:,1)=dx1;
img2(:,:,2)=img1(:,:,2);
img2(:,:,3)=img1(:,:,3);
rslt=ycbcr2rgb(uint8(img2));
end
S=rslt;
% Q=imread('coridor1.jpg');
% figure, imshow(Q)
% figure, imshow(R)


Quote
edgecolor_prewit.m
%Finding edges of a color image
%Usage edgecolor('female.jpg');


function S=edgecolor(nm);
img=imread(nm);
[x y z]=size(img);
if z==1
rslt=edge(img,'canny');
elseif z==3
img1=rgb2ycbcr(img);
dx1=edge(img1(:,:,1),'canny');
dx1=(dx1*255);
img2(:,:,1)=dx1;
img2(:,:,2)=img1(:,:,2);
img2(:,:,3)=img1(:,:,3);
rslt=ycbcr2rgb(uint8(img2));
end
S=rslt;
% Q=imread('coridor1.jpg');
% figure, imshow(Q)
% figure, imshow(R)


Quote
edgecolo_sobel.m
function R=edgecolor(nm);
img=imread(nm);
[x y z]=size(img);
if z==1
rslt=edge(img,'log');
elseif z==3
img1=rgb2ycbcr(img);
dx1=edge(img1(:,:,1),'log');
dx1=(dx1*255);
img2(:,:,1)=dx1;
img2(:,:,2)=img1(:,:,2);
img2(:,:,3)=img1(:,:,3);
rslt=ycbcr2rgb(uint8(img2));
end
R=rslt;
% Q=imread('coridor1.jpg');
% figure, imshow(R)
% figure, imshow(Q)


and the image

Thanks a lot in advance! PLEASE PLEASE PLEASE HEEELP!!!

Offline kambinatoR

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Help detect the end of the corridor of an image
« Reply #1 on: July 23, 2009, 10:00:28 AM »
PLEASE Somebody HELP!!!

Matlab and SimuLink Development Forum

Re: Help detect the end of the corridor of an image
« Reply #1 on: July 23, 2009, 10:00:28 AM »