Remove all existing rectangles within a png image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
anas
Posts: 4
Joined: 2017-07-19T09:04:14-07:00
Authentication code: 1151

Remove all existing rectangles within a png image

Post by anas »

Hello,

I am a newbie to Imagemagick, I would like to remove all existing rectangles within a png image. First question : Is it possible to do such thing using this tool ?
  • If yes, how could I do it (feel free to supply additional information (I'm curious) )?
  • If no, which tool can I use in order to do such things ?
Image

About the other questions :
  • IM version : 6.9.8-10 Q8 x64
  • Platform : Windows
Question for snibgo : What you mean by transparent (Would you replace the current pixels by surronding pixels) ?
For this image, the goal is to clear all rectangles so there still only text. the rectangles would be replaced by white pixels ideally. (as I don't understand what you mean clearly by transparent )


Thanks in advance,
Last edited by anas on 2017-07-20T05:52:01-07:00, edited 4 times in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove all existing rectangles within a png image

Post by snibgo »

What do you mean by "rectangles"? Sample image, please. What do you mean by "remove"? Make those pixels some other colour? Or transparent? What version of IM? On what platform?
snibgo's IM pages: im.snibgo.com
anas
Posts: 4
Joined: 2017-07-19T09:04:14-07:00
Authentication code: 1151

Re: Remove all existing rectangles within a png image

Post by anas »

@snibgo I answered your questions, is still remain some other important information that i did not supply ?

This is my first question, feel free to give me advises for better future questions

Thanks in advance :?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove all existing rectangles within a png image

Post by snibgo »

Windows BAT script:

Code: Select all

rem The following turns white dark pixels that
rem form a line 25 or more pixels vertically
rem and then 30 or more horizontally.

set SRC=forms-studio.png

set LEN_V=25
set LEN_H=30

%IM%convert ^
  %SRC% ^
  ( +clone ^
    -threshold 50%% ^
    -write mpr:ORG ^
    -negate ^
    -morphology Erode rectangle:1x%LEN_V% ^
    -mask mpr:ORG -morphology Dilate rectangle:1x%LEN_H% ^
    +mask ^
  ) ^
  -compose Lighten -composite ^
  ( +clone ^
    -threshold 50%% ^
    -write mpr:ORG ^
    -negate ^
    -morphology Erode rectangle:%LEN_H%x1 ^
    -mask mpr:ORG -morphology Dilate rectangle:%LEN_H%x1 ^
    +mask ^
  ) ^
  -compose Lighten -composite ^
  noboxes.png
Image
snibgo's IM pages: im.snibgo.com
anas
Posts: 4
Joined: 2017-07-19T09:04:14-07:00
Authentication code: 1151

Re: Remove all existing rectangles within a png image

Post by anas »

Thank you. As I am curious about this tool, could you please explain the commands ?

Thanks in advance,
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Remove all existing rectangles within a png image

Post by snibgo »

snibgo's IM pages: im.snibgo.com
anas
Posts: 4
Joined: 2017-07-19T09:04:14-07:00
Authentication code: 1151

Re: Remove all existing rectangles within a png image

Post by anas »

Thank you very much,
Post Reply