如何显示图像中特定像素的LA * B *值?

如何显示图像中特定像素的LA * B *值?

问题描述:

以前有代码'pixval on'来显示图像中每个像素的rgb值。
现在已经过时。
我想知道如何为LAB转换图像做同样的事情。如何显示图像中特定像素的LA * B *值?

首先,创建与图像的数字

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)); 

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