I am trying to select a particular region using MATLAB. Before extracting the sub matrix I am defining the region using plot command.
figure,imshow(imgc,[0,3000]);
hold on;
plot([x1,x2],[y1,y1],'Color','r','LineWidth',0.5)
hold on;
plot([x1,x1],[y1,y2],'Color','r','LineWidth',0.5)
hold on;
plot([x2,x2],[y1,y2],'Color','r','LineWidth',0.5)
hold on;
plot([x1,x2],[y2,y2],'Color','r','LineWidth',0.5)
hold on;
After plotting,I extract this region.
ROI=img(x1:x2,y1:y2);
img(x1:x2,y1:y2)=0;
However the region plotted and the sub matrix are different as in the figure:
The red box is the plot of region of interest,the region of the 0s is the extracted sub matrix.Ideally the red box should be around the region of 0s. The blue lines are the axes