# MATLAB MATLAB Beginner, Need Help with Histograms

#### n1caboose

Hello PF,

I'm doing research over the summer and have to learn MatLab. I just installed it yesterday and was able to put together a basic script for my project but want to know how to do a couple things.

My project involves analyzing the absorption of a solution by shining a laser through the solution and measuring the resulting intensity with a CMOS camera from ThorLabs. My code is fairly simple and all it does is limit the output CMOS image to a target area as I specify a center and a radius and use the equation of a circle to "crop" the rest of the area around it out. The end goal of the project is to use the intensity map in conjunction with Beer's Law to determine concetrations of the solutions. Here is the code:

xcen = 150;
ycen = 150;

[rows, cols] = size(myimage);
for c = 1:cols
for r = 1:rows
if sqrt((r-xcen)^2 + (c-ycen)^2) < radius
end;
end;
end;

The histogram that is spit out is in color and I'm not too sure why that is after looking at the API. The image is fully greyscale with greyscale setting turned on in photoshop. SO:

tl;dr

1) How do I convert the output data from a greyscale image to a non-color histogram (attached)? EDIT: I figured out I can change the color scheme manually to greyscale after the image comes up, but is it possible to put this in the script? - I don't want to change this manually every time.

2) How do I access the data that the histogram uses? One of my goals is to be able to manipulate the data so I can have in the end Frequency vs. Real Intensity (I want to apply a scaling factor to convert to experimental intensity). What I mean by this is if the intensity on the x-axis currently reads 150 for a group of values, I want to change that to a real intensity value by multiplying all the values of the data by a certain constant. 150 is NOT the real intensity that is determined by the sensor and is just a value that is given by Matlab.

3) How may I change the axes of the Histogram? I don't want 300 to be the maximum Frequency amount every time - it makes it difficult to interpret a color histogram.

Thanks!

#### Attachments

• 19.1 KB Views: 351
Last edited:
Related Math Software Workshop News on Phys.org

"MATLAB Beginner, Need Help with Histograms"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving