imshow, imcrop and imread to set a predefined coordinate system to analyze images

2 次查看(过去 30 天)
Hello,
I have a code shown below that analyzes images to quantify a predefined value termed CTR (basically how bright something is against a background)... I want to set a predefined coordinate system instead of always having to select the area to analyze in each image when I have +50 images. I was wondering what I would need to do to make this adjustment and if anyone had any advice on how to do this.
The code is seen below:
close all clear all
%Images should be labled X.jpg, where X is an integer from 1 to Npics. %Enter number of images to be analyzed.
Npics = 46;
pic = [1:1:Npics]; for n = 1:1:Npics
I = imread(num2str(pic(n)),'jpg');
G = rgb2gray(I);
figure(1),imshow(G),title(['Press enter to crop TISSUE section ',num2str(n)]);
pause;
GT = imcrop(G);
M = mean(mean(GT));
figure(1),imshow(G),title(['Press enter to crop CONTRAST section ',num2str(n)]);
pause;
GC = imcrop(G);
C = mean(mean(GC));
mat(n,1) = M;
mat(n,2) = C;
for k = size(mat,1)
CTR(k) = 20.*log10(mat(k,2)./mat(k,1));
end
end
close all

回答(1 个)

Jean-Marie Sainthillier
编辑:Jean-Marie Sainthillier 2016-10-20
For the first image use :
[GT,rec] = imcrop(G);
(rec is a 4-element vector with the form [XMIN YMIN WIDTH HEIGHT])
For others images, you can re-use directly (non-interactively) theses coordinates with :
GC = imcrop(G,rec);

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by