Image combination of a selected feature / image processing

1 view (last 30 days)
Hi,
I want to combine two images. the firts one is the original image and the second one is the inside contour of the hole. I want to combine these two images and make the inside contour black and obtain a final image having the inside area black.
I added the original image and the contour image that I could generate by using image processing and I also add a representative final image that I want to achieve by using image processing.
Can you help me :)

Answers (2)

Akash
Akash on 6 Sep 2023
Hi,
I understand that you have an original image and a contour image representing the inside contour of a hole. You would like to combine these two images and create a final image.
To achieve this, you can utilize the MATLAB function "imfuse". This function allows you to create a composition of two images, "originalImage" and "contourImage". If the images have different sizes, "imfuse" pads the smaller dimensions with zeros to make both images the same size before creating the composite. The resulting combined image, "fusedImage", is a numeric matrix.
You can refer to the following example as a starting point:
% Read the original image and the contour image
originalImage = imread('original_image.jpg');
contourImage = imread('contour_image.jpg');
% Convert the contour image to binary (if necessary)
contourImage = imbinarize(contourImage);
% Combine the images using imfuse
fusedImage = imfuse(originalImage, contourImage, 'blend');
% Display the fused image
imshow(fusedImage);
The above code combines the original image and contour image to produce the combined image.
Please note that you may need to preprocess the contour image, such as converting it to binary using "imbinarize", depending on its format and characteristics.
For more detailed information and examples, I recommend referring to the MATLAB documentation on "imfuse". You can find it in the below link.

Image Analyst
Image Analyst on 6 Sep 2023
You want to invert your mask (second image) and use it as logical indexes to your original image (grayImage).
grayImage(~mask) = 0;
This will make grayImage look exactly like your third image.

Community Treasure Hunt

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

Start Hunting!