필터 지우기
필터 지우기

Finding the RGB value of a .fig at given X and Y locations

조회 수: 3 (최근 30일)
Madeleine Groves
Madeleine Groves 2016년 4월 6일
댓글: Madeleine Groves 2016년 4월 7일
Hello there may be a really straight forward way to do this that I can't work out but basically...
I want to open up a matlab figure which looks like this and be able to find the RGB values at specific X and Y coordinates that I enter for example x = -122.078519830603 y = 59.3516220639968.
I can do something like this with the data cursor but I have a large number of x and y locations that I need the RGB values for and so would like to write it into my code.
Thanks for any help!
  댓글 수: 4
Madeleine Groves
Madeleine Groves 2016년 4월 6일
Hi Muhammad it's a map. I run a script that produces this colormap from my data (a .fig file). I don't want to save it as an image file as I want to use the specific X and Y values to get the color data at that point on the map.
Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 4월 6일
편집: Muhammad Usman Saleem 2016년 4월 6일
see my answer below. Firstly save this map in tiff or jpeg format and then try my solution

댓글을 달려면 로그인하십시오.

채택된 답변

Chad Greene
Chad Greene 2016년 4월 6일
I wrote colorpicker to get rgb values from mouse clicks on a figure. You could modify colorpicker to use specified coordinates instead of mouse clicks.
  댓글 수: 1
Madeleine Groves
Madeleine Groves 2016년 4월 7일
Thank you your clickz function does what I was wanting to do without having to find what z value the RGB relates to and has solved my problem.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 4월 6일
편집: Muhammad Usman Saleem 2016년 4월 6일
x=imread('YourImage');
  • Images are matrices (2D if grayscale, 3D if colored) in MATLAB.
  • You can use x(i,j) to access a pixel at location (i,j) in a grayscale image.
  • If the image is colored, you can use x(i,j,:) to access the r, g, b values in a 3-vector, respectively. If you need individual channels, then, you can use x(i,j,1) for red for example.
  • You may read to learn this page more.
  댓글 수: 4
Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 4월 7일
what is your prescription about -x,-y?
It is coordinates of the frame in which image has open. Are you know georeference image/ Ungeoreference image??
This function run smoothly for all inputs even on -x,y, if gray value at this location exited! You are trying to get where there no DN value at this location! @Adam
Adam
Adam 2016년 4월 7일
Well, I don't know what the author of the question has in mind, but it seems clear some sort of interpolation has to be done if they want to query such a specific point because it will not exist on the grid, even if negative integers are appropriately shifted to be interpreted as indices into the image.
I assume that a value is still required to be calculated for these cases rather than just a "no value exists at this location" type of error.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2016년 4월 6일
You can use impixelinfo() to have a little status bar on your GUI that gives you the x and y and RGB values as you mouse around the image. It's easy - I do it all the time.
  댓글 수: 4
Image Analyst
Image Analyst 2016년 4월 6일
If you know the coordinates in advance, just hard code them in, like Muhammad showed.
Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 4월 7일
@Image you are my teacher. I want to learn from you a lot of new stuff..
Stay bless always

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by