How to obtain image intensity values of images
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Moon Shadow
el 17 de Feb. de 2014
Comentada: Image Analyst
el 18 de Feb. de 2014
I want to obtain image intensity values at any three selected points of the original eight.tif image.
0 comentarios
Respuesta aceptada
Image Analyst
el 18 de Feb. de 2014
Try impixel() or just indexing
intensity1 = grayImage(y1, x1);
intensity2 = grayImage(y2, x2);
intensity3 = grayImage(y3, x3);
x and y are any INTEGER values that you want inside the boundaries of the image. If you need to user to select them, use ginput(3);
[x,y] = ginput(3); % User to select 3 points.
x = int32(x); % Round and cast to integer.
y = int32(y);
intensity1 = grayImage(y(1), x(1));
intensity2 = grayImage(y(2), x(2));
intensity3 = grayImage(y(3), x(3));
5 comentarios
Image Analyst
el 18 de Feb. de 2014
I tried it and it worked fine. Are you saying that no intensity1, intensity2, and intensity3 were created? Did you look in the workspace panel for them? Here, here's the same code just fancied up a bit. See if it errors out or does not tell you the intensity values. It works fine for me.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Read in image.
fileName = 'eight.tif';
grayImage = imread(fileName);
imshow(grayImage);
axis on;
title(fileName, 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
promptMessage = sprintf('Click on 3 points in the image,\nor click cancel to quit?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return;
end
% Let user click 3 points.
[x,y] = ginput(3)
% Plot those points over the image.
hold on;
plot(x, y, 'r+', 'MarkerSize', 40, 'LineWidth', 5);
% Convert to integers so we can get row and column indexes.
x = int32(x)
y = int32(y)
% Extract the gray level values from the pixels.
intensity1 = grayImage(y(1), x(1))
intensity2 = grayImage(y(2), x(2))
intensity3 = grayImage(y(3), x(3))
% Announce results.
message = sprintf('The intensity at (%d, %d) = %d.\nThe intensity at (%d, %d) = %d.\nThe intensity at (%d, %d) = %d.\n',...
x(1), y(1), intensity1, x(2), y(2), intensity2, x(3), y(3), intensity3);
uiwait(helpdlg(message));
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!