Image Transformation - Histogram Shifting

12 ビュー (過去 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