How to combine two images in specific position for binary masking?
Show older comments
Hello, I am trying to produce some binary masks. The masks I need should be size of 1024X796 pixels. I will at first divide it in four quadrant, then 8X8 blocks etc. Now to produce this, I tried to put the quadrant blocks incribed in the corner of the whole image. I used imresize and then montage to produce the masks with four images. I used get(CData) for exact pixel size of the image, but I am getting 928X720 pixels images. How can I get the same size image for the masks I need. I also tried with ROI, but could not solve it. I have provided the code and images here.
clc
clear all
close all
%get quadrant images
q1 = imread('C:\Users\sharm\Desktop\center figuring block masks\desired images\q1.jpg');
q2 = imread('C:\Users\sharm\Desktop\center figuring block masks\desired images\q2.jpg');
q3 = imread('C:\Users\sharm\Desktop\center figuring block masks\desired images\q3.jpg');
q4 = imread('C:\Users\sharm\Desktop\center figuring block masks\desired images\q4.jpg');
%resize the images into half
k1 = imresize(q1,0.5);
k2 = imresize(q2,0.5);
k3 = imresize(q3,0.5);
k4 = imresize(q4,0.5);
%imshow(k1);
%defining original image and resizing into half
Image = zeros(796,1024);
%figure;imshow(Image);
% I = imfuse(Image,k1);
% figure;imshow(I);
% h = images.roi.Rectangle(gca,'Position',[512,0,512,398],'StripeColor','r');
% mask = createMask(h);
% I = Image(mask);
% figure;imshow(I);
I = imresize(Image,0.5);
imshow(I);
%using montage to plot images side by side and writing them
figure; m1 = montage({I,k1,I,I});
m1=get(m1,'CData');
imwrite(m1,'m1.jpg');
figure; m2 = montage({I,k2,I,I});
m2=get(m2,'CData');
imwrite(m2,'m2.jpg');
figure; m3 = montage({I,k3,I,I});
m3=get(m3,'CData');
imwrite(m3,'m3.jpg');
figure; m4 = montage({I,k4,I,I});
m4=get(m4,'CData');
imwrite(m4,'m4.jpg');
1 Comment
DGM
on 27 Aug 2021
montage() is a tool for viewing images. It's not intended for compositing images. Just the same as with imshow(), the result is dependent on the figure size and is subject to nearest-neighbor interpolation. It's tantamount to taking a screenshot. It's one step up from taking a picture of the screen with a cell phone.
Lemme take a look at this and see what the options are.
Accepted Answer
More Answers (0)
Categories
Find more on Display Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!