How to remove a percentage of image counting from the bottom to top

조회 수: 5 (최근 30일)
Hi
I want to subtract a portion of image (e.g. 30% of it from the top). How do I do that?
If I do, something like this,
img = (croppedImage - (croppedImage.*0.3));
I usually get a 30% deduction from the bottom of it. I want this deduction to be from the top.
Moreover, I need a method to translate the deduction to number of rows. To be known, how many pixel rows this 30% of the image is.
Any ideas please?
  댓글 수: 1
Rik
Rik 2019년 1월 30일
Do you want to change the size of your image, or the ensities that make up that image?

댓글을 달려면 로그인하십시오.

채택된 답변

Mark Sherstan
Mark Sherstan 2019년 1월 30일
편집: Mark Sherstan 2019년 1월 30일
Look at the example I wrote for you below. Use the size function and realize that imcrop takes an array in the form of [xPosition yPosition width height] where the (0,0) point is the top left corner of your image.
I = imread('test.png');
[height width dims] = size(I);
J = imcrop(I,[0 floor(height*0.3) width height-floor(height*0.3)]);
figure(1)
subplot(1,2,1); imshow(I)
subplot(1,2,2); imshow(J)
  댓글 수: 3
Mark Sherstan
Mark Sherstan 2019년 1월 30일
Glad it worked! You could do something along the lines of this:
I = imread('test.png');
[height width dims] = size(I);
rows30 = floor(height*0.3) % I used floor but you can use ceil, round, etc...
Stelios Fanourakis
Stelios Fanourakis 2019년 1월 30일
Thank you so much Mark once again.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by