Automatic cropping
5 views (last 30 days)
Show older comments
I have a cbir system and the output results depends on the cropping of the query image boundary and has to be the same as the cropping of the image boundary in the database. so i was wondering is there a way to crop an image automatically. e.g i do edge detection which gives outlines of the image. i want to crop a certain part of the image automatically. image is a numberplate i want automatic cropping of the image to only include the characters of the number plate and not any other extra little characters unless necessary if the letters mix in with the tiny characters.
an example would be good.
i.e.
this is the start of my code
a=imread(numberplate.jpg);
gr=rgb2gray(a);
bw=im2bw(gr);
edge=edge(bw,'canny',[0.15, 0.3])
crp=imcrop(edge)
This is manual i need automatic.
thanks
Answers (15)
Jack
on 18 Apr 2011
1 Comment
Walter Roberson
on 18 Apr 2011
At your level of understanding, you should never name a structure followed by a field, only a structure followed by an index followed by a field. reg(K).BoundingBox for K from 1 to length(reg)
You might perhaps be wanting to find the bounding box that encloses all of the bounding boxes you found through edge detection; if so then you should be thinking about min() and max().
There _are_ some useful things you can do with naming a structure name and then a field name with no index, but your first order of duty is to get the code working; optimization can come afterwards.
Walter Roberson
on 8 Apr 2011
Do you have code now to detect the portion of the image which is the license plate?
0 Comments
Sean de Wolski
on 8 Apr 2011
Copy and paste that into a script||function and it'll be automatic.
2 Comments
Sean de Wolski
on 11 Apr 2011
First off, don't overwrite the MATLAB function EDGE when you name the variable EDGE!
Could you just find the bounding box of the edge image using regionprops and extract it/save it etc? The rest is just manipulating the string for imread. You could do that with a variety of ways but you haven't made anything clear to us as to how what you want automated.
As Walter and I said before; assuming that your above code works (which we agreed it probably doesn't since numberplate.jpg should be in single quotes); everything else IS automated if you put it in a script and run it.
0 Comments
Wolfgang Schwanghart
on 11 Apr 2011
You might find this function useful: http://www.mathworks.com/matlabcentral/fileexchange/25354-cropmat
HTH, Wolfgang
0 Comments
Jack
on 14 Apr 2011
1 Comment
Sean de Wolski
on 14 Apr 2011
That will give the coordinates for the boundingbox of each object. Read the documentation!!
Jack
on 20 Apr 2011
1 Comment
Sean de Wolski
on 20 Apr 2011
Assuming that BoundingBox is 1x4 (i.e. it was a 2d image) then this looks correct to me. What results did you attain? Did it work?
priya
on 20 Apr 2011
I guess this should work... (not sure though). when you do imcrop() you should be able to right click and get the co-ordinates of the image which you have selected for croping.
%ime1 = findimage();
a=imread(numberplate.jpg);
gr=rgb2gray(ime1);
% BW=im2bw(gr);
edit=edge(gr,'canny',[0.15, 0.3])
im1 = imcrop(edit,[100.5 101.5 456 87]); imshow(im1);
0 Comments
LAXMI NARAYAN SONI
on 7 May 2017
Edited: Walter Roberson
on 14 May 2017
if u have a yellow color no. plate then u can use color based cropping... ike u can crop only yellow color. as simple as that.
clc
clear all
close all
a = imread('car3.jpg');
%b=imshow(a)
red = a(:,:,1);
green = a(:,:,2);
blue = a(:,:,3);
figure,imshow(red);
figure,imshow(green);
figure,imshow(blue);
%d = impixel(a);
i=size(a)
for c=0:i
if a(:,:,1)>13 or <255
if a(:,:,2)>0 or <201
if a(:,:,3)>0 or <104
d = imcrop(a);
figure,imshow(d)
end
end
end
end
1 Comment
Samreen kayani
on 9 Jan 2019
i want to segment each letter individually but bounding box divid 1 into 11 instead of 1.12 my answere is 11.112
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!