McMa
McMa

Reputation: 1566

MatLab reducing bitdepth in plotted images?

I am plotting the feature matches between two scenes like this:

%...import, preprocessing, and stuff

%"Sandwich" Image1 and Image2 in a new image Image
ImSize=[size(Image1,1)+size(Image2,1),max(size(Image2,2),size(Image2,2))];

Image=zeros(ImSize);
Image(1:size(Image1,1),1:size(Image1,2))=Image1;
Image(size(Image1,1)+1:end,1:size(Image2,2))=Image2;

%show Image
imshow(Image,[]);
hold on

%plot keypoints and matching lines in all colors
cc=hsv(size(Keypoints1,1));

for ii=1:size(Keypoints1,1)

    plot(Keypoints1(ii,1),Keypoints1(ii,2),'o','color',cc(ii,:))
    plot(Keypoints2(ii,1),Keypoints2(ii,2)+size(Image1,1),'o','color',cc(ii,:))

    line([Keypoints1(ii,1),Keypoints2(ii,1)],[Keypoints1(ii,2),Keypoints2(ii,2)+size(Image1,1)],'color',cc(ii,:),'LineWidth',0.5)
end

This normaly works alright and Matlab plots the entire bitdepth enter image description here

but with increasing number of lines, I will start seeing a reduction in the bitdepth leading to binary images and even all black: enter image description here

I know plotting this many lines is far from ideal, but still I would like to know why this is happening. Are there any mechanisms of matlab figures I should understand to explain this behaviour?

Note: this is only a problem displaying the images, saving them as .bmp,jpg,... will produce normal pictures.

Upvotes: 5

Views: 92

Answers (1)

kusi
kusi

Reputation: 187

try different renderers? Add this at the beginning of your script

h=figure;
set(h,'renderer','opengl');

Instead of 'opengl', also try 'painters' and 'zbuffer'

Upvotes: 2

Related Questions