Paint bucket tool

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?".
User avatar
bazza
Posts: 20
Joined: 2016-06-15T18:06:36-07:00
Authentication code: 1151
Location: Argntina

Re: Paint bucket tool

Post by bazza »

wow! I go to test this!

Code: Select all

convert j01.png -connected-components 4 -auto-level linesCheck.png
convert.im6: unrecognized option `-connected-components' @ error/convert.c/ConvertImageCommand/1107.

this not found
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Paint bucket tool

Post by snibgo »

What version of IM are you using? "-connected-components" is fairly recent.
snibgo's IM pages: im.snibgo.com
User avatar
bazza
Posts: 20
Joined: 2016-06-15T18:06:36-07:00
Authentication code: 1151
Location: Argntina

Re: Paint bucket tool

Post by bazza »

I wish to convert your script in bash :(
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Paint bucket tool

Post by snibgo »

My script above is quite simple and primitive, joining line-ends that are less than a certain threshold apart. The new line that joins existing line-ends has stroke-width=1. It is easily modified to make the new line the same stroke-width as the average of lines already present.

If the lines are always straight, Hough lines can find intersections.

When two lines are at an angle to each other, and the lines are thick and perhaps curved, we can erase (make transparent) a circle or square at the mid-point of the two ends, and fill that hole eg with "-process fillholespri". Then the two lines will be extended until they intersect (provided the intersection point is within the erased circle). The extensions will match the stroke-width etc of the lines already present. However, the extensions will still be straight.

I don't know of a method that will join line-ends with a curved line.
snibgo's IM pages: im.snibgo.com
User avatar
bazza
Posts: 20
Joined: 2016-06-15T18:06:36-07:00
Authentication code: 1151
Location: Argntina

Re: Paint bucket tool

Post by bazza »

I go to try do something alike.
My original idea was not to repair the lineas if not painting without doing him case to these gaps

I like me to me what armed, but I want to use it in gnu/linux.
User avatar
bazza
Posts: 20
Joined: 2016-06-15T18:06:36-07:00
Authentication code: 1151
Location: Argntina

Re: Paint bucket tool

Post by bazza »

Code: Select all

#!/bin/bash

LIMITE=10
PUNTOS=$(convert \
  $1 \
  -fill White -opaque Red \
  +write linesBroken.png \
  -negate \
  -morphology Thinning:-1 Skeleton +channel \
  -morphology HMT LineEnds \
  txt:- | grep FFFFFF | cut -d: -f1)

PARCHE=$(for A in $PUNTOS; do
        for B in $PUNTOS; do
                echo "dump: $A $B" > /dev/stderr
                [ "$A" == "$B" ] && continue

                X1=$(echo $A | cut -d, -f1)
                X2=$(echo $B | cut -d, -f1)
                Y1=$(echo $A | cut -d, -f2)
                Y2=$(echo $B | cut -d, -f2)
                XX=$(echo $((X1-X2)) | sed 's/-//')
                YY=$(echo $((Y1-Y2)) | sed 's/-//')
                [ "$XX" -lt "$LIMITE" ] && [ "$YY" -lt "$LIMITE" ]&& echo " -draw \"line $A $B\" "
        done
done)


echo convert $1 -stroke red -strokewidth 0 $PARCHE $1.linea.png
convert $1 -stroke red -strokewidth 0 $PARCHE $1.linea.png
I arm this script that do some line red to join the lines
Post Reply