Page 1 of 1

Remove all existing rectangles within a png image

Posted: 2017-07-20T03:40:12-07:00
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,

Re: Remove all existing rectangles within a png image

Posted: 2017-07-20T04:08:16-07:00
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?

Re: Remove all existing rectangles within a png image

Posted: 2017-07-20T07:25:48-07:00
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 :?

Re: Remove all existing rectangles within a png image

Posted: 2017-07-20T08:02:34-07:00
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

Re: Remove all existing rectangles within a png image

Posted: 2017-07-20T08:11:25-07:00
by anas
Thank you. As I am curious about this tool, could you please explain the commands ?

Thanks in advance,

Re: Remove all existing rectangles within a png image

Posted: 2017-07-20T08:26:25-07:00
by snibgo

Re: Remove all existing rectangles within a png image

Posted: 2017-07-20T08:30:22-07:00
by anas
Thank you very much,