Bubble shape detection and creating of the mask

2 次查看(过去 30 天)
Dear Matlab community,
I am totally new in the image processing. Nevertheless, I need to define the bubble on image, create mask and apply the mask to the original image. If someone can help me or give any useful advice, I will be really thankful.
Issue: I have a set of images (2000 for example) at which the bubble is growing and I need to define the bubble shape at each image and apply it for the its original.
I guess that it may be really easy (or not), I just have no any idea. I've already read a number of articles which dedicated the processing issues, but still have not solved problem.
So, I attached original image and three images after some manipulations. It doesn't matter which image you can offer to process. Thanks in advance!
Original:
Processed_1:
Processed_2:
  5 个评论
Aleksandr Bashkatov
Aleksandr Bashkatov 2017-12-17
Thanks, I will try use imellipse. Actually, may be it would be better.
Thanks again!
Best regards, Aleksandr
Aleksandr Bashkatov
Aleksandr Bashkatov 2017-12-18
编辑:Aleksandr Bashkatov 2017-12-18
Dear Image Analyst,
I am sorry for my stupid question again=) Now, I almost solved my problem by means of imellipse.
However, now I have one more question. Hopefully that I didn't waste your time.
My code which I used now:
srcFiles = dir('C:\path\*.tif');
OutVideoDir = 'C:\path\Out';
for i = 1 : length(srcFiles)
filename = strcat('C:\path\',srcFiles(i).name);
I = imread(filename);
figure;
imshow(I,[]);
h = imellipse(gca, [326 455 236 236]);
addNewPositionCallback(h,@(p) title(mat2str(p,3)));
fcn = makeConstrainToRectFcn('imellipse',get(gca,'XLim'),get(gca,'YLim'));
setPositionConstraintFcn(h,fcn);
k = imellipse(gca, [326 1255 236 236]);
l = imellipse(gca, [324 2060 236 236]);
m = imellipse(gca, [324 2860 236 236]);
%accepted_pos = wait(h)
BW1 = createMask(h);
BW2 = createMask(k);
BW3 = createMask(l);
BW4 = createMask(m);
BW = BW1+BW2+BW3+BW4;
BW = 1-BW;
% subplot(1,2,1), imshow(BW), title('Mask');
maskedImage=I .* cast(BW, class(I));
%subplot(1,2,2), imshow(maskedImage,[]), title('Masked image');
baseFileName = sprintf('%d.tif', i);
fullFileName = fullfile(OutVideoDir, baseFileName);
imwrite(maskedImage, fullFileName);
close
end
So, I need to process a number of images (the ellipse will growth - I will add function of the coordinate changing later). When I run the process - it works. But each time, the window with the image is opened, due to the "imshow(I,[]);". And it is really interfere the work on the PC. These windows with the image bar constantly "flickers". Can you maybe give an advice how to hide this process? Thanks in advance!
Best regards, Aleksandr

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2017-12-18
Get rid of this line of code:
figure;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by