2011-12-20 40 views

回答

1

首先,創建與圖像的數字

function so1 
    global im; 
    im = imread('peppers.png'); 
    figure;imshow(im);  
end 

然後,創建一個新的數據光標,選擇 「選擇文本更新FUNC」 enter image description here

,並選擇以下回調文件:

function output_txt = NewCallback(obj,event_obj) 
% Display the position of the data cursor 
% obj   Currently not used (empty) 
% event_obj Handle to event object 
% output_txt Data cursor text string (string or cell array of strings). 
global im; 
pos = get(event_obj,'Position'); 
val = squeeze(im(pos(2),pos(1),:))'; 
srgb2lab = makecform('srgb2lab'); 
labVal = applycform(val,srgb2lab); 
output_txt = sprintf('LAB = [%d,%d,%d]',labVal(1),labVal(2),labVal(3)); 

這裏唯一的缺點是醜陋的使用全局,這可能會被刪除,但這不是問題。

相關問題