Urgent help for Image extraction for object detection using MATLAB

2 Ansichten (letzte 30 Tage)
Subham Verma
Subham Verma am 1 Aug. 2018
Bearbeitet: Subham Verma am 1 Aug. 2018
Hello friends, I am working on an object detection project and I am unable to extract small windows from my image. I am using Harris Corner detector to detect corners. The corner_detector() returns C which is a binary image where every detected corner is denoted as 1 or white pixel and rest are black or 0. Using these corners as my central point, I have to extract 4 windows neighbouring it i.e. top-left, top-right, bottom-left, bottom-right windows of certain dimension. Here is the code for it:
function [R] = preSelection (~, SF, ~, fThr, vThr, sThr)
I = imread('C:\Users\verma\Desktop\image1_resized.jpg');
J = I;
C = corner_detector(J);
%figure, imshow(I)
%figure, imshow(C)
[m,n] = size(C);
t = [0.5,1,2,3,5];
for i=1:m
for j=1:n
for k=1:size(t)
m1 = t(k) * 150;
n1 = t(k) * 250;
Win1 = rand(m1,n1);
Win2 = rand(m1,n1);
Win3 = rand(m1,n1);
Win4 = rand(m1,n1);
if C(i,j) == 1
if (i>m1 && j>n1)
for a=1:m1
for b=1:n1
Win1(a,b,1) = I(i-m1,j-n1,1);
Win1(a,b,2) = I(i-m1,j-n1,2);
Win1(a,b,3) = I(i-m1,j-n1,3);
%Win2 = imcrop(I, [ i (j-n1) m1 n1]);
%Win3 = imcrop(I, [(i-m1) j m1 n1]);
%Win4 = imcrop(I, [ i j m1 n1]);
end
end
end
end
figure, imshow(Win1)
%figure, imshow(Win2)
%figure, imshow(Win3)
%figure, imshow(Win4)
end
end
end
return
Here t is an array which contains some values according to which the selection window will scale itself. It is nothing but a scaling factor. Now the 4 windows are created of a certain dimension and then from I (original image) the pixel values are read and stored in it. I am supposed to generate an output like this (see 3.png). However, no matter what code I write, I always get this as the output (see 4.png). I have also used imcrop also but to no avail (hence, commented out).
What am I doing wrong? What should I do to correct it?
Sample image on which I am testing my code (see image1_resized.jpg).

Antworten (0)

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by