Image processing of spray development and flame propagation using crop and background subtraction
12 次查看(过去 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,
2 个评论
采纳的回答
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 个)
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().
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!