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일
편집: 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