Display image pixel values ​​in octave?

If I upload and display an image like

c = imread('cameraman.tif'); imshow(c) 

then in the chart window, under the image itself, there are two numbers indicating the current cursor position, in the form

 [39.25, 120.6] 

I have two questions:

  • Can I customize the display so that the positions are whole? So, one pixel image per pixel of the screen?
  • Can this information include a grayscale / rgb value for a pixel, for example

    [23, 46] = 127

    or

    [23, 46] = (46,128,210) ?

I tried to mess with the "axis" command, but I did not find anything that helps.

I guess what I want is something like Matlab's β€œPixel Information Tool” impixelinfo : http://www.mathworks.com.au/help/images/ref/impixelinfo.html , although I know from the octave wiki page http://wiki.octave.org/Image_package , which impixelinfo is currently implemented in Octave. But maybe there is another way to achieve the same result?

I am using Octave-3.8.0, the 2.2.0 image package, under Linux (Ubuntu 12.04).

+7
image plot pixels octave
source share
1 answer

GNU Octave 3.8 uses FLTK as standard toolkit graphics. Unfortunately, WindowButtonMotionFcn is launched only if the button is pressed when the mouse moves (drags) using this toolkit (today I would consider this as an error). But you can use WindowButtonDownFcn.

In this example, you are updating the title with the position and value of the image at that position if you click on the image:

 img = imread ("cameraman.png"); imshow (img) function btn_down (obj, evt) cp = get (gca, 'CurrentPoint'); x = round (cp(1, 1)); y = round (cp(1, 2)); img = get (findobj (gca, "type", "image"), "cdata"); img_v = NA; if (x > 0 && y > 0 && x <= columns (img) && y <= rows (img)) img_v = squeeze (img(y, x, :)); endif if (numel (img_v) == 3) # rgb image title(gca, sprintf ("(%i, %i) = %i, %i, %i", x, y, img_v(1), img_v(2), img_v(3))); elseif (numel (img_v) == 1) # gray image title(gca, sprintf ("(%i, %i) = %i", x, y, img_v)); endif endfunction set (gcf, 'WindowButtonDownFcn', @btn_down); 

You can also put text next to the cursor if you wish.

+5
source share

All Articles