Hi
I would like to draw a figure -> save it as an greyscale image and put it on top of another image. When I plot combined image there is a white frame around the drawn image. When I run the following example I get the shown image. When i prope the value in the white frame is shows the correct greyscale value.
Does anyone know what I am doing wrong and know how to fix it?
(Ps. the reason that I do not just draw directly on the first image is because I would like to do transformations of the drawn image using the tools in matlab before it is added on top of the other.)
bg = randn(700,1000);length = 300; %[pixels]
width = 400; %[pixels][sizey,sizex] = size(bg);xstart = (sizex-length)/2;ystart = (sizey-width)/2;xcor = [xstart, xstart, xstart+length, xstart+length, xstart];ycor = [ystart, ystart+width, ystart+width, ystart, ystart];figure('Position', [100, 100, length, width]); %Make figure in "true size"
set(gca,'color','none')patch(xcor, ycor,'green')axis offaxis imageF = getframe(gcf);[specimen,~] = frame2im(F);specimen = im2double(rgb2gray(specimen)); % image of the drawn rectangle
imshow(specimen)bg(1:400,1:300) = specimen; % putting the image on top of each other.
imshow(bg)
Best Answer