Message Boards Message Boards

0
|
3836 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to eliminate the border in a rasterized image?

Posted 2 years ago

I am trying to create a mask for image processing. Below is a typical code for the mask. I added the pink background to highlight the problem. I would like this to be a 450x450 image, without the pink border. How should I do it?

Rasterize[
 Graphics[{Yellow, Rectangle[{1, 1}, {450, 450}], Black, 
   Polygon[{{1, 163}, {243, 450}, {450, 219}, {450, 450}, {1, 
      450}}]}], "Image", RasterSize -> 450, Background -> Pink] 

enter image description here

POSTED BY: Claudio Argento
3 Replies

You can also try ImageCrop, which is precisely for this kind of purpose. Unfortunately, I always confuse it with ImageTrim.

POSTED BY: Gianluca Gorni

Hi,

would this work?

Rasterize[
 Graphics[{Yellow, Rectangle[{1, 1}, {450, 450}], Black, 
   Polygon[{{1, 163}, {243, 450}, {450, 219}, {450, 450}, {1, 450}}]},
   PlotRangePadding -> None], "Image", RasterSize -> 450, 
 Background -> Pink]

Cheers, Marco

POSTED BY: Marco Thiel

Yes it does... I should have looked at the options in more detail. Thank you Marco

POSTED BY: Claudio Argento
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract