Hi all, Can any one tel me the command in matlab to calculate the intensity of image.

2 件のコメント

Jean
Jean 2013 年 7 月 5 日
Does anyone further know how to do this for a specific area of pixels? For example, image(100:1:200,100:1:200) for a 100 by 100 pixel area, and get the intensity in this area as an average?
Image Analyst
Image Analyst 2013 年 7 月 5 日
編集済み: Walter Roberson 2014 年 2 月 11 日
meanGrayLevel = mean2(yourImage(100:200,100:200));
Don't use "image" as the name of your variable since it's a function.

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2012 年 6 月 4 日

6 投票

The mean of a particular pixel is just simply the pixel value, since there is only one sample - nothing really to take the mean of:
intensityValue = grayImage(100, 230);
meanIntensityValue = mean(grayImage(100, 230));
Here, of course meanIntensityValue will equal intensityValue.
To get the mean of all the pixel values in the entire image, you can do any of these:
meanIntensityValue = mean2(grayImage);
meanIntensityValue = mean(grayImage(:));
meanIntensityValue = mean(mean(grayImage));

13 件のコメント

M@lik Ali
M@lik Ali 2012 年 6 月 4 日
thanks for the response
Can we calculate the intensity like this
grayImage = rgb2gray(I);
[M N d] = size(grayImage);
intensityValue=0;
count=0;
for x = 1:M
for y = 1:N
intensityValue = intensityValue + uint32(grayImage(x,y)) ;
end;
end;
Image Analyst
Image Analyst 2012 年 6 月 4 日
Yes, if you divide that by M*N, and if you want to do it much much slower than my method.
Mona
Mona 2013 年 6 月 25 日
I want the average of the intensities of all pixels. does this work on 3D hyperscectral image?
meanIntensityValue = = mean(HyperImage(:));
Mona
Mona 2013 年 6 月 25 日
or
meanIntensityValue = mean2(HyperImage);
Iain
Iain 2013 年 6 月 25 日
Yes. Both should work. (Though, you have a spare "=" in the first one).
Mona
Mona 2013 年 6 月 26 日
Thank you so much
Image Analyst
Image Analyst 2013 年 6 月 26 日
編集済み: Image Analyst 2013 年 6 月 26 日
Please mark the discussion as "Answered" if you're done with it. Unless you want to open a can of confusing worms about how the units of an image are not really intensity.
Samantha Villanueva
Samantha Villanueva 2020 年 9 月 9 日
hello can I use this to a colored image?
Image Analyst
Image Analyst 2020 年 9 月 10 日
You would have to do it on every color channel independently:
[r, g, b] = imsplit(rgbImage);
meanRed = mean2(r);
meanGreen = mean2(g);
meanBlue = mean2(b);
Walter Roberson
Walter Roberson 2020 年 9 月 10 日
As the question is about mean intensity, then which definition of "intensity" do you want to use for your RGB image?
Jitin Malhotra
Jitin Malhotra 2021 年 6 月 9 日
verticalProfile = sum(testimage, 2);
figure; barh(verticalProfile);
so i put a threshold on the sum from vertical profile say at sum of 70000, removing all pixels based on this sum. Then what would be the units of this threshold value 70000? Will i call this pixels or brightness value, intensity value, what would i call them?
Walter Roberson
Walter Roberson 2021 年 6 月 9 日
If you are using a grayscale image in which the values are "brightness" (as opposed to something like Hue), then the real unit would be closer to "brightness per pixel^2". Summing that over a number of pixels in a row or column would give you "brightness per pixel^2 * pixels" which would be "brightness per pixel".
... Brightness would not be the real physical unit. Eyes do not perceive brightness in a linear manner. https://www.pathwaylighting.com/products/downloads/brochure/technical_materials_1466797044_Linear+vs+Logarithmic+Dimming+White+Paper.pdf
"Approximate perceived brightness = sqrt(measured brightness)"
I just woke up, and digging into luminance and chromaticities and transfer functions this early in my day is making my brain hurt. @Image Analyst studied those things, so he would be in a much better position to talk about what the real physical units would be.
Image Analyst
Image Analyst 2021 年 6 月 10 日
The usual nomenclature of your vertical profile (the image summed horizontally across columns) is "integrated gray value" and it will have units of gray levels. For a standard digital camera which measures illuminance Lux or irradiance (watts per square meter), the units of gray level correspond to units of energy (Joules).
(watts/m^2) * (area of pixel in m^2) * (seconds of exposure time) = joules.
Note that watts = joules/second so everything cancels out except for joules.
Note: units prefixed with "Phot" or "Lum" (like illuminance) refer to radiation in the visible range 400-700 nm. If it doesn't have a prefix or has "rad" prefix (like irradiance), then it applies to all energy across the whole electromagnetic spectrum.

サインインしてコメントする。

その他の回答 (4 件)

swetha Derangula
swetha Derangula 2017 年 8 月 5 日
編集済み: Walter Roberson 2017 年 8 月 5 日

1 投票

Is this code correct for entire image intensity? I didn't get any intensity value
clear all;
close all;
o=imread('450.jpg');
i=rgb2gray(o);
imshow(i)
intensityValue = i(100, 230);
meanIntensityValue = mean(mean(i));
please suggets me

2 件のコメント

Walter Roberson
Walter Roberson 2017 年 8 月 5 日
No code that contains "clear all" can be correct.
Your line
intensityValue = i(100, 230);
extracts one particular pixel's intensity, and only that one pixel. However,
meanIntensityValue = mean(mean(i));
should be fine for taking the mean intensity of the entire image.
Image Analyst
Image Analyst 2017 年 8 月 6 日
You could also use mean2().

サインインしてコメントする。

Adina Stoica
Adina Stoica 2012 年 6 月 4 日

0 投票

Well, the intensity of the image is the average of the intensities of all pixels in an image (unless you're doing anything more specific than that). So if you do
mean(imagefile(:))
you should get the intensity of the image.

1 件のコメント

M@lik Ali
M@lik Ali 2012 年 6 月 4 日
編集済み: Walter Roberson 2014 年 2 月 11 日
Adina thanks for your response,
But actually i want to calculate the intensity value of all elements of the images.
someone told me like
intensityValue = grayImage(100, 230);
But in i have to calculate the intensity value of each pixel or total image, i think i can do it by calculating the intensity of each pixel and then add it but i am not sure.
Kindly help me about it..

サインインしてコメントする。

Saranya
Saranya 2014 年 1 月 30 日

0 投票

hi image analyst i want to measure the intensity profile for gray scale image.. can you help me..?

18 件のコメント

Image Analyst
Image Analyst 2014 年 1 月 30 日
You can use the improfile() function to do that.
Saranya
Saranya 2014 年 1 月 31 日
編集済み: Walter Roberson 2014 年 2 月 11 日
clc; clear all; close all;
I used this command sir but its not working.. this is my input image http://postimg.org/image/pe5ozahzb/e770bd0c/
[f p] = uigetfile('*.jpg');
I = imread([p f]);
J = rgb2gray(I);
improfile()
Image Analyst
Image Analyst 2014 年 1 月 31 日
You're not taking the result of improfile. What variable to you want to use to accept the intensity numbers from improfile()?
lineProfile = improfile().
Saranya
Saranya 2014 年 2 月 1 日
編集済み: Image Analyst 2014 年 2 月 1 日
still am not getting the answer sir..
[f p] = uigetfile('*.jpg');
I = imread([p f]);
J = rgb2gray(I);
c = improfile();
I need a plot with X and Y axis. so that the lowest intensity will be the centromere position
Image Analyst
Image Analyst 2014 年 2 月 1 日
Well you never plotted it! You need to call plot(). Try this:
fontSize = 20;
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
filePattern = fullfile(folder, '*.jpg')
[f p] = uigetfile(filePattern);
subplot(2, 1, 1);
originalImage = imread([p f]);
grayImage = rgb2gray(originalImage);
imshow(grayImage);
title('Original Image', 'FontSize', fontSize);
axis on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
uiwait(msgbox('Left click, then right click'));
c = improfile();
subplot(2, 1, 2);
plot(c, 'LineWidth', 3);
grid on;
title('Intensity Profile', 'FontSize', fontSize);
Saranya
Saranya 2014 年 2 月 3 日
Thank you very much sir. I got the result.
Saranya
Saranya 2014 年 2 月 3 日
Sir, Is there any way to get the intensity profile automatically. i.e., without drawing the line manually?
Image Analyst
Image Analyst 2014 年 2 月 3 日
Yes. improfile() can take arguments that are the endpoints of the line.
Jensa
Jensa 2014 年 2 月 11 日
Hi Image Analyst...Can you help me to find the density profile for my chromosome image..Attaching the image along with this.. http://postimg.org/image/pe5ozahzb/e770bd0c/
Image Analyst
Image Analyst 2014 年 2 月 11 日
Please start your own discusssion.
Rasika Devi
Rasika Devi 2017 年 3 月 20 日
hello image analyst. i want to know how to calculate the weight of an image?
Walter Roberson
Walter Roberson 2017 年 3 月 20 日
Rasika Devi, could you confirm that you want to be able to calculate the number of photons that would be emitted to display a particular image for a particular length of time, and you would want to convert the photon energies into equivalent rest mass using E = m*c^2, in order to calculate the mass of the image? And then we should assume one standard Earth gravity in order to convert mass into weight (since weight is a force) ?
Rasika Devi
Rasika Devi 2017 年 3 月 20 日
thank you sir, but in matlab there is cmd as graydiffweight() how to use this for image? can you help me?
Walter Roberson
Walter Roberson 2017 年 3 月 20 日
I had never heard of that before.
Rasika Devi
Rasika Devi 2017 年 3 月 20 日
then how can i complete the weight selection problem for the grayscale image?
Walter Roberson
Walter Roberson 2017 年 3 月 20 日
It looks like you just have to pick either a representative pixel or a representative level and call graydiffweight() passing in the data and the location or level.
Rasika Devi
Rasika Devi 2017 年 3 月 21 日
編集済み: Rasika Devi 2017 年 3 月 21 日
Thank you so much sir.. One more thing from that weight value,how do i perform the image segmentation by using any algorithm? kindly help me...
Walter Roberson
Walter Roberson 2017 年 3 月 21 日
I suggest you look in the File Exchange, for Image Analyst's Image Segmentation Tutorial

サインインしてコメントする。

Syakira Akmal
Syakira Akmal 2017 年 4 月 3 日

0 投票

May I know how to convert intensity of image inform of histogram?

1 件のコメント

Image Analyst
Image Analyst 2017 年 4 月 3 日
[counts, grayLevels] = imhist(grayImage);

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by