필터 지우기
필터 지우기

How to convert two rgb images into grayscale? and then subtract ?

조회 수: 2 (최근 30일)
swati mane
swati mane 2019년 3월 18일
답변: Image Analyst 2021년 6월 19일
I have two images in jpg format(one as reference image and other is captured image) . I want to convert them to grayscale and want to subtract them. How to do this?
Thanks in Advance.
  댓글 수: 3
Jan
Jan 2019년 3월 19일
@swati mane: Does this comment concern my answer? Is your problem solved?
swati mane
swati mane 2019년 3월 19일
Hello sir,
My problem resolved. thank you!!!

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

채택된 답변

Jan
Jan 2019년 3월 18일
img1 = imread('Image1.jpg');
img2 = imread('Image2.jpg');
D = rgb2gray(img1) - rgb2gray(img2)

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 6월 19일
If you don't want negative numbers clipped to zero you can cast to double before subtracting
image1 = imread('Image1.jpg');
image2 = imread('Image2.jpg');
diffImage = double(rgb2gray(image1)) - double(rgb2gray(image2));
imshow(diffImage, []); % Make sure you use []
If you just want the absolute value of the difference, use imabsdiff():
diffImage = imabsdiff(image1, image2);
No need to cast to double in that case.

카테고리

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