user5184777
user5184777

Reputation:

how to perform image enhancement over a small region of an image?

I would like to enhance a portion of the image. I would like to enhance the regions within rectangular region esp on the green rectangle region

Upvotes: 0

Views: 72

Answers (2)

NKN
NKN

Reputation: 6424

Using a function like ginput you can select a point on an image, and with having a width and height values of a rectangle, you can crop a rectangle from your image. Then you can use any function such as imadjust to enhance your cropped part.

a= 100;                             % height
b= 100;                             % width 
I = imread('myimage.png');          % read the image file
figure;imagesc(I);                  % plot the image
[x,y] = ginput(1);                  % select a point
I2 = I(:,:,1);                      %
Ic = imcrop(I2,[x-a/2 y-b/2 a b]);  % crop a rectangle around the selected point
J = imadjust(Ic);                   % adjust the contrast

If you want to be able to select a rectangle, you can use the following command:

imshow('myimage.png');
rect = getrect;

Upvotes: 1

kkuilla
kkuilla

Reputation: 2256

You can use imcrop.

[I2 rect] = imcrop(I)

This will ask you to draw a rectangle and rect will thus contain the coordinates of that rectangle. I2 contains the cropped image and you can then apply any function you would like on that matrix.

Upvotes: 1

Related Questions