How to save an image in this situation quickly without using 'saveas' and 'insertShape'?

I want to generate an image like this. Initially i just have an processed image, then i need to plot mask (the blue one) over the image and save it, by using imshow diplay the image and then plot lines over it, i do get the result.
The problem is, if i use imshow and then plot mask over image, for exporting i must use 'saveas' or 'print', but this is a disaster for lots of high resolution images, it will be exdremely slow.
For this reason i tried the 'insertShape', this function adds lines directly in image matrix, then using 'imwrite' to save image will be much more quicker than 'saveas' or 'print', but here is the problem! you can see 'insertShape' produces wrong and incomplete lines (inside the yellow circle), and this is more serious when i process high resolution image.
So is there a third way to quickly export image with masks? Thanks a lot

4 commentaires

Can I see the "insertShape" command that you are using to create a shape on the image? I tried inserting a shape on an image of size 13000 x 6700. After saving the image using "imwrite" I checked it, looks fine to me.
Hello,
this is my code, the loop is for combining all masks, 'Points' is all vertices coordinate of one mask. That 'FullImage' is the processed image. Hope this is helpful.
Thanks.
for j = 1:MaskNum
Points = Mask{2,j};
[a,~] = size(Points);
B{j} = reshape(Points.',1,a*2);
end
withline =
insertShape(FullImage,'Polygon',B,'LineWidth',8,'color',color*255);
imwrite(withline,s)
Using a large line width creates problems with the caps at every turn because no curvature or bezelling is applied.
This is the same problem as the earlier thread:
Given that this problem only occurs for certain vertex lists, and only seems to occur when multiple polygons are given in a single call to insertShape(), then I would not call this expected behavior.

Connectez-vous pour commenter.

Réponses (0)

Question posée :

le 21 Juil 2018

Commenté :

DGM
le 12 Sep 2023

Community Treasure Hunt

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

Start Hunting!

Translated by