필터 지우기
필터 지우기

I am trying to display an image of covariance(covariance map) using this code but I receive a false result , please would you help me with this (I need this for my master degree)

조회 수: 4 (최근 30일)
clc
close all
clear all
img = imread('C:\test\image\image1.jpg'); %lire l'image de reference
I = rgb2gray(img); %convertir en niveau de gris
I1 = medfilt2(I, [5 5]);
C=imcrop(I1, [18.5 29.5 31 29]); %imcrop an ROI(left ventricular)
[m,n]=size(C);
for i=1:m
for j=1:n
for num=1:16
file=['image', num2str(num),'.','jpg'];
im = im2double(imread(fullfile('C:\test\image', file)));
im = rgb2gray(im); %convertir en niveau de gris
I2 = medfilt2(im, [5 5]);
C=imcrop(I2,[18.5 29.5 31 29]);
a(i,j)= C(i,j);
C1 = imcrop(C, [20.5 16.5 5 4]); %ROI2 inside the first ROI
[m1,n1]= size(C1);
end
mua(i,j)=((1/16)*(sum(C(i,j))));
end
end
for num=1:16
for i=1:m1
for j=1:n1
a1(i,j)=C1(i,j);
end
end
AR(num)=((1/(m1*n1))*(a1(i,j))); %%%%%%%%%%%%
end
% %
for i=1:m1
for j=1:n1
muar =((1/16)*sum(AR));
end
end
for i=1:m1
for j=1:n1
for num=1:16
cov(i,j) = sum((a1(i,j) - mua(i,j))*(AR - muar));
end
covtot(i,j) = ((1/16)*sum(cov(i,j)));
end
end
figure(1);
imagesc(covtot),title('image de covariance'),
colorbar, colormap(jet);
  댓글 수: 10
chaima kadess
chaima kadess 2018년 9월 11일
no ,I am working with a sequence of 16 images and I want to display finally one image of covariance from this 16 images.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 9월 11일
You should replace a bunch of your code.
numimg = 16;
mut = zeros(m, n);
for num = 1:numimg
file = ['image', num2str(num),'.','jpg'];
im = im2double(imread(fullfile('C:\test\image', file)));
im = rgb2gray(im); %convertir en niveau de gris
I2 = medfilt2(im, [5 5]);
C = imcrop(I2,[18.5 29.5 31 29]);
mut = mut + C;
C1 = imcrop(C, [20.5 16.5 5 4]); %ROI2 inside the first ROI
AR(num) = mean2(C1);
end
mua = mut ./ numimg;
I had to make an assumption here about what you were calculating with mua.
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 9월 12일
If it is the average of a(i,j) over all of the images, then that is what I have the code calculate.
chaima kadess
chaima kadess 2018년 9월 17일
thank you for responding me , but unfortunately it doesn't works , I have a sequence of 16 cardiac images ,the first image will be taken as a reference(c1(i,j)) following this equation : cov(i,j)=(1/T)*((C1(i,j)-mua(i,j))*(AR-muar)) where T is the frame number and mua(i,j) is the mean of the (i j) pixel value in the image series and AR is the mean value of all pixels located in the region of reference and muar is the mean value of the references series.so i am looking to display an image of the calculated covariance . hopefully you can help me mrs.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by