How to apply a rectangular on images?

I want to apply a rectangular on an image. First I want to click on the image and give the program a point and then apply the rectangular on the image, the point will be the center of the rectangular. after that I want to have the pixel value of the selected area. what should I do?
I found this in other questions: h=imrect(gca,[10 10 100 100]) it will apply rectangular h on the image, how can I give the point by just clicking on the image by myself since I do not know the start point for rectangular, this rectangular will start from point (10 10), I want the point which I select be the center of the rectangular not the starting point. and after that I want to work on the pixel value of pixels inside the rectangular. what should I do?

Answers (1)

Why not just call imcrop()?

4 Comments

I don't want to crop the image. just want to have information inside the rectangular, with cropping the image I wrote this code : p=impoint(gca); pos=getPosition(p); pos=round(pos); x=pos(1);y=pos(2); rect=[x y 5 5]; I2=imcrop(I,rect);
instead of this code which will crop the image, how can I have only rectangular and inside pixels information ? I don't want to do cropping
rectangular is an adjective. I have no idea what that might be if it's not the pixels inside the rectangular region that you drew with imcrop() or rbbox(). Explain exactly what "inside pixels" means to you if it's not the cropped image pixels grayImage(row1:row2, column1:column2) that are inside the box defined by row1, row2, column1, and column2.
I mean I don't want to crop the image, cause I think it will take time for the program,because I have more than 1000 pictures. imcrop will exactly do what I want. But I guess by cropping it will take time, I just want the rectangular act as a window and give me roi of the rectangular. by applying the rectangular I want to introduce a new roi and have pixel intensity of that area.
You either crop it, and work on the sub image, or you don't and need to take care to never have indexes outside row1, row2, col1, and col2. Either way, I don't care.

This question is closed.

Asked:

on 10 Jan 2015

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!