4

How to view the pixel intensities of an image in matlab by moving the mouse pointer over the image?

I used:

imshow(imread('image.jpg'));

But there is no option to view the pixel intensities of each pixel in the image.

For example,

      In MS-paint, while moving the mouse pointer 
      over the image we can see the location of 
      the pixel such as (20, 117) at the status bar. 

But I need to see the pixel intensity instead.

Is there any other option to view it. Or I need to code to view it?

Shai
  • 111,146
  • 38
  • 238
  • 371
user2522560
  • 783
  • 1
  • 7
  • 13

3 Answers3

2

One other option which is more interactive is

   imtool(imread('image.jpg')); % For GrayScale Image

   imtool(rgb2gray(imread('image.jpg')));  % For RGB Image
user2522560
  • 783
  • 1
  • 7
  • 13
1

If you want to create an intensity map, you can use MATLAB's rgb2gray. This will convert the n-by-m-by-3 RGB array you got from imread to an n-by-m matrix which contains the pixel intensities.

You can then point the interactive data cursor to this intensity matrix for the current mouse coordinates.

Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
  • 2
    Thank you. Its working. I just typed two lines imshow(imread('image.jpg'));datacursormode on; Now By moving the cursor on the image the intensities are displayed along with the X,Y,Z coordinates. – user2522560 Jul 10 '13 at 06:04
  • @user2522560: oh wow, even simpler; did not know that :) Well, good for you! Remember that you can mark this answer as accepted by clicking the big "tick" mark next to it. – Rody Oldenhuis Jul 10 '13 at 06:08
  • 1
    For gray scale image it works, For RGB image we need to convert the image to rgb using rgb2gray and then proceed further like this imshow(rgb2gray(imread('image.jpg'))); datacursormode on; You are right. Thank you. – user2522560 Jul 10 '13 at 06:25
0

you have impixelinfo and impixelinfoval for showing interactive information.

Shai
  • 111,146
  • 38
  • 238
  • 371