How to get pixel value from a color map?

In summary, The conversation discusses a python code that generates two 1D arrays and plots them using a scatter plot. It also draws a colorbar using a normalization range. The question posed is how to find individual values at the pixel points on the plot, given only two 1D arrays. The response clarifies that the desired outcome is to retrieve the mass values at those points on the plot.
  • #1
Atr cheema
69
0
I have a python code where it generates two 1D arrays, plots them using scatter plot and then draws colorbar using normalization range. How can I find individual values at those individual pixel points?

Python:
HC = data["HC"]
OC  = data["OC"]
sample = y
widthmm, heightmm = 171, 233
ratio = (widthmm/2.0)/(heightmm/4.0)
widthinch = widthmm/25.40
fig = plt.figure(figsize=(widthinch,widthinch/ratio))
ax1 = fig.add_subplot(111)
ax1 = plt.hexbin(OC,HC,cmap=glocmap,bins=None,gridsize=(20,15),alpha=0.75,mincnt=1,vmax=50,linewidth=0,vmin=7)

CvarLab = 0
cb = plt.colorbar(ax1)
cb.set_label(CvarLab,size=20)
cb.ax.tick_params(labelsize=20)
cb.set_alpha(1)
cb.draw_all()

and it generates a plot like this .My question is how can I find values of 'Mass' on those individual points shown in image given than we have only two 1 dimensional arrays?
 
Technology news on Phys.org
  • #2
What is it you're wanting to do? is it to show the mass values on the plot? or to get the colors the mass values were assigned?
 
  • #3
jedishrfu said:
What is it you're wanting to do? is it to show the mass values on the plot? or to get the colors the mass values were assigned?
I want to get mass values at those individual points on the plot.
 

FAQ: How to get pixel value from a color map?

What is a color map?

A color map, also known as a colormap or color palette, is a range of colors that are used to represent data in a visual form, such as an image or graph. Each color in the map is assigned a specific value or range of values.

How do I access the pixel values from a color map?

To access the pixel values from a color map, you will need to identify the specific color or range of colors that you are interested in. You can then use a function or method to retrieve the corresponding numerical value for that color.

Can I get the pixel value from a color map in different color spaces?

Yes, different color spaces such as RGB, CMYK, and HSV may use different color maps. When accessing pixel values from a color map, it is important to specify the color space in which the values are represented.

How do I know which color corresponds to a specific pixel value?

Typically, a color map will have a legend or color bar that displays the range of values and their corresponding colors. You can use this guide to determine which color corresponds to a specific pixel value. Alternatively, you can use a color picker tool to identify the color of a specific pixel in the image or graph.

Are there any tools or libraries that can help with accessing pixel values from a color map?

Yes, there are several tools and libraries available that can assist with accessing pixel values from a color map. Some popular examples include OpenCV, Matplotlib, and ImageJ. These tools provide functions and methods for retrieving pixel values from a color map in various programming languages.

Back
Top