Please provide a solution for how to find a correlation value for 300 frames by considering its pixel values and stored it in array or some memory space. For example if we found correlation of first and second image, we will get one correlation value like 0.9. Then we should find a correlation between second and third image, third and fourth, etc. Like this how to find for 300 adjacent images.

 채택된 답변

Austin Thai
Austin Thai 2021년 4월 17일

0 개 추천

You can use the 2-D correlation coefficient function
corr2(A,B)
Depending on how the data for your frames are stored, you can write a for loop to compare consecutive pairs.
For example, if you had a 3D array of frames called frameArray that is 512x512x300 :
imageCorrelation=zeros(299,1)
for i=1:299
imageCorrelation(i)=corr2(frameArray(:,:,i),frameArray(:,:,i+1))
end

댓글 수: 16

SUJITH D S
SUJITH D S 2021년 4월 17일
I'm having frame 0 to frame 299 in single folder
Austin Thai
Austin Thai 2021년 4월 17일
편집: Austin Thai 2021년 4월 18일
Are you asking how to read the frames into matlab? I don't know what your filenames look like, but you should try the imread function first:
frameArray=zeros(512,512,300)
for i=1:300
frameArray(:,:,i)=imread(['frame' num2str(i-1) '.tif'])
end
Edit: I just realized you want 0 to 299 instead of 1 to 300. This should work then. Use this to import the frames and run the corr2 for loop in the main answer to get the coefficients. Just modify the filenames appropriately.
SUJITH D S
SUJITH D S 2021년 4월 17일
yea first i should read the 300 frames from frame0 to frame 299 which is stored in a folder... Then i should calculate the correlation of those 300 frames and that correlation values should be store in array sir
SUJITH D S
SUJITH D S 2021년 4월 17일
for corr2() which are the parameters i should pass.
Because frame0 to frame299 are in single folder.... Should I pass the whole folder... If i should can u please say how to pass
SUJITH D S
SUJITH D S 2021년 4월 17일
Can u provide complete code please
Austin Thai
Austin Thai 2021년 4월 17일
Give me the name of your folder and an example name of your file.
SUJITH D S
SUJITH D S 2021년 4월 17일
folder name is images... file name is frame0
Austin Thai
Austin Thai 2021년 4월 17일
What's the filetype?
SUJITH D S
SUJITH D S 2021년 4월 17일
frame0.jpg
Austin Thai
Austin Thai 2021년 4월 17일
편집: Austin Thai 2021년 4월 18일
Okay, so if you're running in a directory containing the subdirectory "images", you can run the full code as:
frameArray=zeros(512,512,300)
for i=1:300
frameArray(:,:,i)=imread(['images/frame' num2str(i-1) '.jpg'])
end
imageCorrelation=zeros(299,1)
for i=1:299
imageCorrelation(i)=corr2(frameArray(:,:,i),frameArray(:,:,i+1))
end
SUJITH D S
SUJITH D S 2021년 4월 17일
Thank you so much sir
SUJITH D S
SUJITH D S 2021년 4월 17일
sir if there are 298 images... which value should be changed sir??
Austin Thai
Austin Thai 2021년 4월 17일
편집: Austin Thai 2021년 4월 18일
I assume you're going from frame0 to frame297 now? Just modify the matrix sizes and for loop indices appropriately:
frameArray=zeros(512,512,298)
for i=1:298
frameArray(:,:,i)=imread(['images/frame' num2str(i-1) '.jpg'])
end
imageCorrelation=zeros(297,1)
for i=1:297
imageCorrelation(i)=corr2(frameArray(:,:,i),frameArray(:,:,i+1))
end
SUJITH D S
SUJITH D S 2021년 4월 17일
No sir frame0 to frame298
SUJITH D S
SUJITH D S 2021년 4월 17일
Please change and send the code sir it's more important for me sir please
SUJITH D S
SUJITH D S 2021년 4월 18일
Please can u solve this below error sir... I'm getting an error like this...
Subscripted assignment dimension mismatch.
Error in matlab1 (line 3)
frameArray(:,:,i)=imread(['images/frame' num2str(i-1) '.jpg'])

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

추가 답변 (0개)

질문:

2021년 4월 17일

댓글:

2021년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by