Image Transformation - Histogram Shifting

조회 수: 15 (최근 30일)
Sanghyeon Yi
Sanghyeon Yi 2019년 1월 29일
편집: Walter Roberson 2019년 9월 11일
Hello,
I am new to Matlab and I am trying to transform a grayscale image with histogram shifting. The idea is like the screen shot below.
How can I set the image range between 25 and 225 and shift +50 in Matlab?
I have a code only for gray image part.
flower = imread('FlowerN.jpg');
gray = rgb2gray(flower);
%%i'm lost here..
for i=1:length(gray)
i>25 AND i<225
i = i+50
end
Thank you,
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 9월 11일
William Stamatis comments,
This question is directly from Homework #2 in Georgia Tech's Fall 2019 ISYE 8803 Topics on High Dimensional Data Analytics class--it should be removed (I'm a fellow student in the class)
Walter Roberson
Walter Roberson 2019년 9월 11일
William:
The question cannot be from the class you note: the question was posted 8 months ago, not Fall 2019.
It is not against the rules to post questions about homework here and ask about the techniques that would be used in MATLAB to solve the technical issues. We discourage volunteers from providing complete solutions to homework; we encourage volunteers to educate the people posting the questions.
In most universities it would be plagiarism to copy an answer directly from here and use it in code. It is not, however, a problem to learn techniques from answers posted here and express them your own way.

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

답변 (2개)

Shunichi Kusano
Shunichi Kusano 2019년 2월 4일
If a value is added to all the pixels, the histogram shifts to the right.
MATLAB commands are:
brighter = gray + 50; % histogram shift to the right
% setting the value range between 25 to 225;
brighter(brighter > 225) = 225;
brighter(brighter < 25) = 25;
hope this helps.

Walter Roberson
Walter Roberson 2019년 9월 11일
편집: Walter Roberson 2019년 9월 11일
This would be a good situation in which to use https://blogs.mathworks.com/steve/2008/01/28/logical-indexing/ logical indexing.
mask = YourArray meets some condition
YourArray(mask) = YourArray(mask) + something
There is another approach available using max() and min()
min( max( transformed_array, Lower_Bound), Upper_Bound)
The way this works is often confusing; I always have to hesitate and re-think the logic whenever I write this kind of code.

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by