Finding upperleft corner of bounding box where i am having centroid of bounding box and height and width of bounding box.

Hi i am learning matlab and i have my assignment so i have this centroid of the bounding box of object and width and height of the bounding box, now i need to find the upper left corner of the bounding box, as my frame contain multiple objects i want to select only this object and mask everything else as 0 or gray. please help me with this.
the code i have managed to write till nw is clear all; %% Opening files f1='GT1.txt'; f2 = 'target1_PF.txt'; F1 = fopen (f1); abc = textscan (F1, '%s %s %s %s %s'); a1 = (abc{1,2}); b1 = (abc{1,3}); c1 = (abc{1,4}); d1 = (abc{1,5}); F2 = fopen (f2); def = textscan (F2, '%s %s %s %s %s %s'); a2 = (def{1,3}); b2 = (def{1,4}); c2 = (def{1,5}); d2 = (def{1,6});
%%Extracting Data and Processing
for i =1:149
x1 = str2num(cell2mat(a1(i)));
y1 = str2num(cell2mat(b1(i)));
w1 = str2num(cell2mat(c1(i)));
h1 = str2num(cell2mat(d1(i)));
x2 = str2num(cell2mat(a2(i)));
y2 = str2num(cell2mat(b2(i)));
w2 = str2num(cell2mat(c2(i)));
h2 = str2num(cell2mat(d2(i)));
half_width = w1/2;
half_height = h1/2;
ul_corner = abs({x1-half_width},{y1-half_height});
end

Answers (0)

Asked:

on 15 Feb 2012

Community Treasure Hunt

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

Start Hunting!