Hello PF,(adsbygoogle = window.adsbygoogle || []).push({});

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:

myimage = imread('/Users/[myName]/Desktop/greyscaletest2.bmp');

radius = 70;

xcen = 150;

ycen = 150;

[rows, cols] = size(myimage);

myMaskedImage = zeros (rows, cols);

for c = 1:cols

for r = 1:rows

if sqrt((r-xcen)^2 + (c-ycen)^2) < radius

myMaskedImage(r,c) = myimage(r,c);

end;

end;

end;

hist (double(myMaskedImage))

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!

**Physics Forums - The Fusion of Science and Community**

# MATLAB Beginner, Need Help with Histograms

Have something to add?

- Similar discussions for: MATLAB Beginner, Need Help with Histograms

Loading...

**Physics Forums - The Fusion of Science and Community**