Automatic cropping

조회 수: 2 (최근 30일)
Jack
Jack 2011년 4월 8일
편집: DGM 2023년 2월 12일
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

답변 (6개)

Walter Roberson
Walter Roberson 2011년 4월 8일
Do you have code now to detect the portion of the image which is the license plate?

Sean de Wolski
Sean de Wolski 2011년 4월 8일
Copy and paste that into a script||function and it'll be automatic.
  댓글 수: 16
Jack
Jack 2011년 4월 22일
이동: DGM 2023년 2월 11일
i tried what you said
when i reach up to reg=regionprops('BoundingBox')
you said to ceil the first two entries i ddn't know which of the 52 coordinates do i look at.
im guessing its is the bound that captures the whole numberplate. through the loop i said.
but when i ceil(first 2 entries i.e. xmin, ymin) then add entries 1 and 2 to 3 and 4 respectively after the ceil func.
its ok up this point but when i do icrop=i(ymin:ymax,xmin:max,:) it says index esceeds matrix dimension or something. if i do Capital I(ymin:ymax,xmin:xmax,:) says undefine function or variable I
i need help with this thanks
LAXMI NARAYAN SONI
LAXMI NARAYAN SONI 2017년 5월 7일
이동: DGM 2023년 2월 11일
Yes this is the right way.... U also have to be use a loop.

댓글을 달려면 로그인하십시오.


Wolfgang Schwanghart
Wolfgang Schwanghart 2011년 4월 11일
HTH, Wolfgang

priya
priya 2011년 4월 20일
편집: DGM 2023년 2월 11일
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);

LAXMI NARAYAN SONI
LAXMI NARAYAN SONI 2017년 5월 7일
편집: Walter Roberson 2017년 5월 14일
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
DGM
DGM 2023년 2월 11일
편집: DGM 2023년 2월 12일
It's a good thing that code isn't even valid, because even in concept, it would accomplish nothing worth the cost of execution.
Consider a 1000x1000x3 RGB image. For each element in the array, you ostensibly want to:
  1. test to see if the entire image is within a prismatic volume within the RGB color space
  2. if it is, display the full image in a window and request that the user interactively select a region with the mouse, right click, and then select "crop image" from a dropdown menu
  3. display the cropped region and then discard it
So either the first test fails and the code does literally nothing but spend time warming your CPU, or you're going to make the user do the exact same manual task three million times. Like I said, it's a good thing that it's not valid syntax.

댓글을 달려면 로그인하십시오.


Samreen kayani
Samreen kayani 2019년 1월 9일
i want to segment each letter individually but bounding box divid 1 into 11 instead of 1.12 my answere is 11.112

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by