Page 2 of 2

Re: Paint bucket tool

Posted: 2016-06-17T06:59:19-07:00
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

Re: Paint bucket tool

Posted: 2016-06-17T07:10:23-07:00
by snibgo
What version of IM are you using? "-connected-components" is fairly recent.

Re: Paint bucket tool

Posted: 2016-06-17T07:16:46-07:00
by bazza
I wish to convert your script in bash :(

Re: Paint bucket tool

Posted: 2016-06-18T23:05:57-07:00
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.

Re: Paint bucket tool

Posted: 2016-06-19T09:10:15-07:00
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.

Re: Paint bucket tool

Posted: 2016-06-19T11:38:11-07:00
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