2011-12-20 76 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)); 

这里唯一的缺点是丑陋的使用全局,这可能会被删除,但这不是问题。

相关问题