How to use mean function for image analysis
18 ビュー (過去 30 日間)
古いコメントを表示
I have a question on an assignment that says:
Use the function mean to create a new variable that is a grayscale image of variable A.
I am aware of how to use the mean function, but confused on how to use it to make a grayscale image. Any help would be very appreciated.
3 件のコメント
Guillaume
2020 年 2 月 25 日
編集済み: Guillaume
2020 年 2 月 25 日
Yes, if that's the whole text of the assignment then you're entitled to complain as the assignment is completely meaningless (pun not intended).
If as Adam suspects the variable A is a true colour image, then note that taking the mean of the colour is a very poor way of converting to greyscale.
Of course, if the assignment doesn't specify what a valid greyscale image of variable A is supposed to be, then:
newvariable = mean(1);
would be a greyscale image of any variable. Not a very useful one, of course...
Wesam Rezk
2021 年 11 月 3 日
To convert RGB image to grayscale with mean function, you have to make sure to assign the output variable of mean function to uint8 since imshow takes this data type as input. Also, it is different when using mean function with matrices as it has different input arguments.
For example
Converting RGB bulitin image peppers in MATLAB to grayscale
A=imread('peppers.png');
% M=mean(A,dim) the input argument dim returns mean along dim
M=mean(A,3); % M has double as data type
N=uint8(M); % Now N is uint8 data type. Converting from double to uint8
imshow(N);
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!