Here's the final code :
global img;
f = figure('color', 'w', 'MenuBar', 'none', 'Position', [500 500 800 600])
global ax;
ax = axes
img = imread('Fleur_3x4.jpg');
imshow(img);
TailleImg = size (img);
global ah;
ah = annotation(f, 'line','Units', 'Pixels', 'Position', [311 183 TailleImg(2) 0], 'Color','k','LineWidth',10);
hold on
set(f, 'Position', [10 10 800 600]);
set(f, 'Resize','off');
set(ax, 'Units', 'Pixels');
set(ax, 'OuterPosition', [1 1 800 600]);
set(ax, 'InnerPosition', [311 191 TailleImg(2) TailleImg(1)]);
set(ax, 'Position', [311 191 TailleImg(2) TailleImg(1)]);;
global Inner;
[Inner] = get(ax, 'InnerPosition');
set (gcf, 'WindowButtonMotionFcn', @mouseMove);
function mouseMove (object, eventdata)
global img;
global ah;
global ax;
global Inner;
CP = round(get (ax, 'CurrentPoint'));
x = CP(1,1)
y = CP(1,2)
IntX = cast(x, 'uint16')
IntY = cast(y, 'uint16')
if IntX < 1
ah.Color=[1, 1, 1];
xlabel(ax, ' ');
return;
end
if IntX > Inner(3)
ah.Color=[1, 1, 1];
xlabel(ax, ' ');
return;
end
if IntY < 1
ah.Color=[1, 1, 1];
xlabel(ax, ' ');
return;
end
if IntY > Inner(4)
ah.Color=[1, 1, 1];
xlabel(ax, ' ');
return;
end
RGB = img(IntY,IntX, :);
Lab = rgb2lab(RGB)
rouge = double(RGB(1,1,1))/ 255.00
vert = double(RGB(1,1,2))/ 255.00
bleu = double(RGB(1,1,3))/ 255.00
ah.Color=[rouge, vert, bleu];
Temp1 = ['(X,Y) = ', num2str(IntX), ', ', num2str(IntY)];
Temp2 = ['RGB = ', num2str(RGB(1,1,1)), ', ', num2str(RGB(1,1,2)), ' , ', num2str(RGB(1,1,3))];
Temp3 = ['Lab = ', num2str(Lab(1,1,1),4), ', ', num2str(Lab(1,1,2),4), ' , ', num2str(Lab(1,1,3),4)];
xlabel(ax, [{Temp1, Temp2, Temp3}]);
end
I'm sure there's plenty of room for lot's of optimizations but, at the stage I'm at, learning Matlab, I feel like putting my feet up. The code would deserve adequate documentation, I know... I still have a ton of work to do, like, this works with one 'single image' but it's a 'proof of concept' for me. At least, I know what to expect now and the results meet my initial goals.