#BUGFIX by stefan
authorStefan Vogel <sv@exept.de>
Thu, 31 Aug 2017 10:38:52 +0200
changeset 8137 4d18d8b42894
parent 8136 e18855468edd
child 8138 7633000935c0
#BUGFIX by stefan class: Color class changed: #best:ditherColorsForImage: Fix shadowed variable in inlined block
Color.st
--- a/Color.st	Wed Aug 30 15:41:46 2017 +0200
+++ b/Color.st	Thu Aug 31 10:38:52 2017 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
@@ -3649,7 +3651,6 @@
         "/
         boxesAlreadySegmented := Set new.
         segments := OrderedCollection new.    
-
         boxesToDo := OrderedCollection new.
 
         "/ each box has 9+9+3+3+1+1 neighbors
@@ -3684,35 +3685,36 @@
                     |rgb|
 
                     rgb := (((r * (boxMaxG+1))+g)*(boxMaxB+1))+b.
-                    (cube at:rgb+1) ~~ 0 ifTrue:[
-                        (boxesAlreadySegmented includes:rgb) ifFalse:[
-                            |currentSegment|
-
-                            "/ start a segment
-                            currentSegment := OrderedCollection new.
-                            segments add:currentSegment.
-
-                            boxesToDo add:rgb.
-                            boxesAlreadySegmented add:rgb.
-
-                            [boxesToDo notEmpty] whileTrue:[
-                                |rgb|
-
-                                rgb := boxesToDo removeLast.
-                                currentSegment add:rgb.
-
-                                enumerateNeighbors value:rgb value:[:n_rgb |
-                                    (cube at:n_rgb+1) ~~ 0 ifTrue:[
-                                        "/ neighbor has used pixels as well...
-                                        (boxesAlreadySegmented includes:n_rgb) ifFalse:[
-                                            "/ neighbor was not processed...
-                                            boxesAlreadySegmented add:rgb.
-                                            boxesToDo add:n_rgb.
-                                        ].
-                                    ].    
-                                ].
-                            ].
-                        ].    
+                    ((cube at:rgb+1) ~~ 0 
+                     and:[(boxesAlreadySegmented includes:rgb) not]) ifTrue:[
+                        |currentSegment|
+
+                        "/ start a segment
+                        currentSegment := OrderedCollection new.
+                        segments add:currentSegment.
+
+                        boxesToDo add:rgb.
+                        boxesAlreadySegmented add:rgb.
+
+                        [boxesToDo notEmpty] whileTrue:[
+                            |lastRgb|
+
+                            lastRgb := boxesToDo removeLast.
+                            currentSegment add:lastRgb.
+
+                            enumerateNeighbors
+                                    value:lastRgb 
+                                    value:[:n_rgb |
+                                        (cube at:n_rgb+1) ~~ 0 ifTrue:[
+                                            "/ neighbor has used pixels as well...
+                                            (boxesAlreadySegmented includes:n_rgb) ifFalse:[
+                                                "/ neighbor was not processed...
+                                                boxesAlreadySegmented add:lastRgb.
+                                                boxesToDo add:n_rgb.
+                                            ].
+                                        ].    
+                                    ].
+                        ].
                     ].    
                 ]
             ]