Trying to understand pixel value.
古いコメントを表示
I am trying to understand pixel value, and trying to learn to alter it. But things act weird in matlab. Correct me if I am wrong but, pixel value is in a way amound of "light" a colour has. 0 means no light= black, 255 full light. Everything in between is something like, light blue dark blue and etc. So I googled "blue 300x300" and used this code:
clc;
clear all;
f = imread('C:\Users\*****\Desktop\images\sfaafsfas.jpg');
for i=0:255
f(f==i)=12;
end
imshow(f)
If I delete for loop, and look at the f value from workshot all the values of the pixel value (at least I think they are pixel values) all of them are 12. Then I add for loop, and check the values, still they are all 12, yet imshow shows me a grey image. It kinda makes sence, yet it does not too. Nothing chages but something changes. What am I missing here?

original

What I get.
7 件のコメント
GMD Baloch
2019 年 2 月 24 日
I don't understand your question what you want to do?
Do you want to alter the pixel values according to your desire or you want to do something else?
"If I delete for loop, and look at the f value from workshot all the values of the pixel value (at least I think they are pixel values) all of them are 12."
Looking is not a very reliable way to test all values in an array. Better:
all(f(:)==12)
"What am I missing here?"
We don't know, because you did not upload a sample image and you did not explain what you expect to happen.
Arda Nova
2019 年 2 月 24 日
Arda Nova
2019 年 2 月 24 日
"think about one pixel, blue, with a pixel value 12, and I change this value to 120. What should be the end result?"
If it is an RGB image (MxNx3) and you increase the blue channel from 12 to 120 then that pixel will be more blue. Of course when mixed with the other two color channels it might be perceived as another color, but it will still be more blue than it was before. It will increase the brightness of the pixel, and probably change the saturation (how depends on the values of the other two channels).
If it is a grayscale image (MxN) then that pixel will increase in brightness.
If is is an indexed image (MxN) then the color will change from color 12 to color 120, whatever they may be.
The MATLAB documentation has a good introduction to the three common bitmap image types:
Arda Nova
2019 年 2 月 24 日
Arda Nova
2019 年 2 月 24 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!