Image processing of spray development and flame propagation using crop and background subtraction

조회 수: 8 (최근 30일)
Hi guys,
I am trying to use Matlab (2021b) to process images that I obtained from a high speed camera used to capture spray development and onset of combustion within the combustion chamer of an optical GDI engine.
What I intend to do is that I would like to make a clear contrast between spray penetration/flame propagation and background image (combustion chamber) so that I have a clear view around the boundary layers.
I have attached background and spray images that I used to produce the processed image by utilising the code "Sutraction". The images that I posted will help you to understand what I want do.
However, due to the vibration of the engine, the origin of each frame taken by the high speed camera ever so slightly fluctuates. As a result, there are some random white dots around each corners.
As a result, I tried to further develop my code "Subtraction_V2" to crop the images first so that I can line up the origin. Also, this will help me to vary the size of the frame; thereby, allowing me to concenrate on certain areas e.g. I can focus on injector tips or I can make an emphasis around both injector and spark plug.
Unfortunately, as I cannot apply the same frame size by dragging to crop "background" & " spray" images, I constantly receive an error indicating that my matrix size does not match. Therefore, when it comes to cropping, I am wondering whether I can select my origin point (for my case, it would be the injector tip) and determine the size of crop frame (not by dragging. Rather by typing coordinate. Something like this). If this is possible, I can completely eliminate the misalignment of the origin caused by the vibration and can freely set my cropping window according to my need.
Your help will be greatly appreciated.
Kind regards,

채택된 답변

DGM
DGM 2021년 11월 21일
There are image registration tools you can use, but if you just want something simple and interactive, consider the following example:
% reference image
BG = rgb2gray(imread('Background.jpg'));
% let's say there are multiple other spray images that are slightly offset
SP{1} = rgb2gray(imread('Spray.jpg'));
SP{2} = circshift(SP{1},[5 7]);
SP{3} = circshift(SP{1},[-7 -10]);
SP{4} = circshift(SP{1},[10 5]);
% show the reference image; use the mouse to pick a reference point
BG = imadjust(BG,[0.25 1]); % adjust contrast for visibility
imshow(BG)
refloc = ginput(1);
% show the other images; pick the same point as before
R = zeros(numel(SP),2);
for f = 1:numel(SP)
thisframe = imadjust(SP{f},[0.25 1]);
imshow(thisframe)
R(f,:) = ginput(1);
end
% approximate size of image intersection
boxshift = max(abs(R-refloc),[],1);
boxsize = fliplr(size(BG))-2*boxshift;
% crop all images to a common geometry
BG = imcrop(BG,[boxshift boxsize]);
for f = 1:numel(SP)
SP{f} = imcrop(SP{f},[boxshift+(R(f,:)-refloc) boxsize]);
end
% image geometries should match
size(BG)
SP
% display images in sequence to visually demonstrate registration
for f = 1:numel(SP)
imshow(SP{f})
pause(0.05)
end
This only compensates for translation error, not rotation or scale error. If you want to crop down to a smaller region of interest, you can do that to the images after they've been registered and cropped to a common geometry. That way the same RECT parameter can be used for all images.
  댓글 수: 1
Dongsu Kim
Dongsu Kim 2021년 11월 24일
First of all, thank you very much for your guidance. I have applied it to my code with some modifications to suit my need. I only need compensation for translation error, so it was perfect to resolve my issue. I will study imregister and imtrnaslate function for later use. Anyway, thanks a lot and hope to see you again for another interesting Matlab code!

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

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 11월 21일
Try imregister() if the frames are similar, just shifted. If you're comparing all frames to frame 0 and they're not similar because frame 0 has no spray in it and later frames do have spray in them, then I'd try to identify landmarks in your image that you can try to register, like a certain dot in the image that's always there. Then crop out that, register it to find the shift vector, and translate the original image with imtranslate().
  댓글 수: 1
Dongsu Kim
Dongsu Kim 2021년 11월 24일
Many thanks for your suggestion. I will try to familiarise with the functions for future development. When I had a look at them, they look pretty fancy. Once again, I really appreciate your help and hope to see you again for future inquiries!

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

카테고리

Help CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by