how to calculate image prediction ?

3 ビュー (過去 30 日間)
narimen boucenna
narimen boucenna 2020 年 7 月 21 日
回答済み: Deepak 2024 年 10 月 17 日
i was asked to calculate correlation between pixels
and then to claculate the prediction of image with this hint :
e(i,j)=img(i,j)- img(i,j-l) if i=0
e(i,j)=img(i,j)-img(i-l,j) if j=0
and then the correlation of this image
anyone can help me please !!,

回答 (1 件)

Deepak
Deepak 2024 年 10 月 17 日
Hi Narimen,
As I understand it, you want to calculate the prediction error image “e (i,j)” of the input image, based on the given hint formulas. You also want to calculate the correlation of this image based on the prediction error image.
To accomplish this task, we can load the input image in MATLAB and convert it to grayscale and double format using thergb2gray” and “double” functions for accurate calculations. Next, we can iterate over the rows and columns of the image using nested for loops to calculate the prediction error image. Finally, we can calculate the correlation of the image by using the corrcoef” function in MATLAB.
Below is the complete MATLAB code to accomplish this task:
img = imread('your_image.jpg');
img = double(rgb2gray(img)); % Convert to grayscale and double for calculations
[rows, cols] = size(img);
% Initialize the prediction error image
e = zeros(rows, cols);
for i = 1:rows
for j = 1:cols
if i == 1 && j > 1
e(i, j) = img(i, j) - img(i, j-1); % Use the previous pixel in the row
elseif j == 1 && i > 1
e(i, j) = img(i, j) - img(i-1, j); % Use the previous pixel in the column
elseif i > 1 && j > 1
% For other pixels, you can choose one of the predictions or a combination
e(i, j) = img(i, j) - img(i-1, j);
end
end
end
% correlation of the prediction error image
correlation = corrcoef(e(:));
disp('Correlation of the prediction error image:');
disp(correlation);
Please find attached documentation of functions used for reference:
I hope this assists in resolving the issue.

Community Treasure Hunt

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

Start Hunting!

Translated by