How do I obtain all rgb pixels from an image instead of just one pixel from user input? And then how do I output that data to a csv file?
3 ビュー (過去 30 日間)
古いコメントを表示
Heres the code
function pushbutton2_Callback(hObject, eventdata, handles)
global R G B range img unit
[col,row] = ginput(1); % Get point position from user
col = fix(col); row = fix(row);
% Create temperature as function in RGB
T = linspace(range(1),range(2),length(R)); T = T';
r = img(row,col,1); % Red component of selected point
g = img(row,col,2); % Green component of selected point
b = img(row,col,3); % Blue component of selected point
%Looking for the closest point on the colormap
for tol = 1:length(R);
idx=((R<r+tol)&(R>r-tol))&((G<g+tol)&(G>g-tol))&((B<b+tol)&(B>b-tol));
t = T(idx);
if ~isempty(t),break,end
end
In trying to change [col,row] = ginput(1) so that it gets all the rgb values and puts them into the temperature equation to then be displayed on a csv file.
0 件のコメント
回答 (1 件)
Image Analyst
2022 年 8 月 12 日
You seem to already have a variable called img. That IS all the pixel values for all locations. If you want just one row, column you can use impixel or do it like you did.
If you want a CSV file, see my attached demo.
2 件のコメント
Image Analyst
2022 年 8 月 12 日
Perhaps
[r, g, b] = imsplit(rgbImage);
mask = ((R<r+tol)&(R>r-tol))&((G<g+tol)&(G>g-tol))&((B<b+tol)&(B>b-tol));
Just operate on the whole images if you want the temperature of the whole image. Don't use ginput() and a for loop. I'm not sure what your temperature equation is.
参考
カテゴリ
Help Center および File Exchange で Subplots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!