parking space using IMAGE PROCESSING

18 views (last 30 days)
clc;
close all;
clear all;
%image acquisition
f=imread('C:\Users\vinoth\Downloads\jph.jpg');
f=imresize(f,[800 NaN]); % image loading unit
figure (1)
imshow(f)
g=rgb2gray(f);
g=medfilt2(g,[5 5]);
figure (2)
imshow (g)
% morphological image processing
conc=strel('disk',5);
gi=imdilate(g,conc);
conc1=strel('disk',5);
ge=imerode(gi,conc1); % morphological image processing
gdiff=imsubtract(gi,ge);
gdiff1=mat2gray(gdiff);
figure (4)
imshow (gdiff1)
gdiff2=conv2(gdiff1,[1 1;1 1]);
figure (5)
imshow (gdiff2)
gdiff3=imadjust(gdiff2,[0.4 0.9],[0 1],1);
figure (6)
imshow (gdiff3)
B=logical(gdiff3);
[a1 b1]=size(B);
figure(7)
imshow(B)
er=imerode(B,strel('line',60,8));
figure(8)
imshow(er)
out1=imsubtract(B,er);
F=imfill(out1,'holes'); %filling the object
H=bwmorph(F,'thin',0.5);
H=imerode(H,strel('line',8,55));
figure(9)
imshow(H)
%Normalization% & Object Recognition
I=bwareaopen(H,floor((a1/18)*(b1/18)));
I(1:floor(.9*a1),1:2)=1;
I(a1:-1:(a1-20),b1:1:(b1-2))=1;
figure(10)
imshow(I)
%Cars detection in image
figure (11)
imshow pair (f,I)
%Create bounding box on detected cars
Iprops=regionprops(I,'BoundingBox','Image');
hold on
text(8,785,strcat('\color{green}Cars Detected:',num2str(length(Iprops))))
hold on
for n=2:size(Iprops,1)
rectangle('Position',Iprops(n).BoundingBox,'EdgeColor','g','LineWidth',2);
end
result = sprintf('Number of cars: %d.',n-1);
disp(result);% display number of cars
hold off
i am trying to do a project for parking space detection using image processing , the above program is the code ive been working on, whenever i am trying to run the code , it shows an error like this
??? Error using ==> imageDisplayParsePVPairs at 72
Invalid input arguments.
Error in ==> imageDisplayParseInputs at 70
[common_args,specific_args] = imageDisplayParsePVPairs(varargin{:});
Error in ==> imshow at 199
[common_args,specific_args] = ...
i am not expert in matlab, i am a student trying to do a report on IMAGE PROCESSING if someone know what is the problem in this code?... if knew explain this to me.. i copied this code i didnt write this...

Accepted Answer

Guillaume
Guillaume on 21 Oct 2019
You've cut the error message and removed the most important bit, the last part which told you which line of your code is responsible for the error.
I'm guessing it may be this line:
imshow pair (f,I)
which should be written
imshowpair(f, I)
with no space between imshow and pair.
  3 Comments
Guillaume
Guillaume on 21 Oct 2019
Maybe it's time to upgrade?
As per its documentation imshowpair requires at least R2012a, so you can't use that function. For this particular case, I think your imshowpair call may be equivalent to:
imshow(cat(3, I, rgb2gray(f), I));

Sign in to comment.

More Answers (1)

Thoms Csa
Thoms Csa on 17 Jan 2020
Hi,
Sorry, this is not an answer, but I'm a student too, trying to do exacly the same report on car detection.
I wonder if you finally found out how to detect cars, and I hope you wouldn't mind sharing your work with me.
Thanks
  1 Comment
Image Analyst
Image Analyst on 17 Jan 2020
Is your camera looking at the same scene? Or do you have multiple different lot locations you're monitoring? Please start a new question and attach your images. You'll need several images, especially one of the lot with no cars at all in them, and possibly at different times of day because that will affect the lighting and shadows on the scene. Plus some images with cars of various colors, especially cars with colors like the asphalt or concrete roadway, which will make it difficult to find those cars.

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!