フィルターのクリア

How to calculate mid value of RGB image in matlab?

1 回表示 (過去 30 日間)
Aarach Sap
Aarach Sap 2016 年 9 月 29 日
コメント済み: Stephen23 2016 年 9 月 29 日
I did
RGB=cast(imread('Lenna.tiff'),'double');
c= mid(RGB(:));
And I got an error saying "Undefined function 'mid' for input arguments of type 'double'"
  3 件のコメント
Aarach Sap
Aarach Sap 2016 年 9 月 29 日
編集済み: Walter Roberson 2016 年 9 月 29 日
I want to calculate max, min, and mid value of RGB image.
M= max(RGB(:));
m= min(RGB(:));
c= mid(RGB(:));
But I got error on mid. How to calculate mid value ?
Stephen23
Stephen23 2016 年 9 月 29 日
You possibly meant to call the median function, where the median is the standard mathematical term for the "mid value" of a set of values:
Or perhaps the mean, where the mean is the standard mathematical term for the "average" of a set of values:

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 9 月 29 日
If you are referring back to that rgb2hsv and hsv2rgb C++ code you posted the link to, https://bitbucket.org/chernov/colormath/src/012a5ae28033dc8e91ec66ec349c95d81caddb71/colormath/hsv.cpp?at=default&fileviewer=file-view-default, then beware.
In the first of the routines there, rgb2hsv, mid is used as a variable that holds a copy of the value of one of the three color components. If you were to vectorize the code, then mid should be an array of values, not a function.
In the second of the routines there, hsv2rgb, mid is used as a pointer to one of the output values r, g, b, and after all the rest of the calculations, the value at that pointer is modified. If you were to vectorize the code, then you would need to make mid an array of indicators of which of the three values is to be modified for that location. The easiest way to do that would be to put your rgb together into a 3D array and then have mid be indices into the third dimension.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by