Issue with image background substraction

1 回表示 (過去 30 日間)
Turbulence Analysis
Turbulence Analysis 2024 年 5 月 2 日
Hi,
I am trying to perform background substraction. Here I have both the main and background images. I tried imsubstract unfortunately that doesn't performing well.
  1 件のコメント
Matt J
Matt J 2024 年 5 月 2 日
編集済み: Matt J 2024 年 5 月 2 日
Your post doesn't show what you did, so it is difficult to speculate what went wrong.

サインインしてコメントする。

採用された回答

DGM
DGM 2024 年 5 月 2 日
編集済み: DGM 2024 年 5 月 3 日
First off, don't save images by taking screenshots of figures. Use imwrite().
Second, if you're going to use the IPT arithmetic tools, you need to know what they do. They are still dependent on class and scale, just like using normal arithmetic operators. Subtracting a light gray background region from a dark gray foreground feature in uint8 will still cause all the foreground information to be destroyed, since negative values can't be represented. Either convert to floating-point and use the absolute difference, or if the images are both the same class and scale, you can use imabsdiff().
inpict = imread('main image.jpg');
bg = imread('background.jpg');
outpict = imabsdiff(inpict,bg); % absolute difference
imshow(outpict,'border','tight')
There are other ways to solve the same problem.
outpict = im2double(inpict)./im2double(bg); % division
imshow(outpict,'border','tight')
In either case, you can use imcomplement() to invert the result if you want to change the polarity.
  1 件のコメント
Turbulence Analysis
Turbulence Analysis 2024 年 5 月 3 日
Thanks very much, DGM!. It's perfect

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by