Re: [Gimp-developer] Detecting "closure" of selection

2010-10-10 Thread Sven Neumann
On Sun, 2010-10-10 at 14:55 +0200, Ofnuts wrote:

> > (let ((count (cdddr (gimp-histogram (car (gimp-image-get-selection image))
> >   HISTOGRAM-VALUE
> >   255
> >   255
> > (= (car count) (cadr count)) ; compare num of all pixels to all white 
> > pixels
> > )
> 
> Exactly what the doctor ordered. Thanks (and to Rob...). However, the 
> only documentation I found of this function was in the API browser of 
> the python-fu console. I couldn't find it in the files I sampled at 
> . Where is it documented?

http://developer.gimp.org/api/2.0/libgimp/libgimp-gimpcolor.html#gimp-histogram


Sven


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Detecting "closure" of selection

2010-10-10 Thread Ofnuts
  On 10/10/2010 04:01, saulgo...@flashingtwelve.brickfilms.com wrote:
> Quoting Ofnuts:
>
>> Is there a practical, fast way, to detect this case, i.e, that the
>> selection covers the whole layer (or image?) and that no pixels remain
>> unselected? I assume that inverting the selection again and testing for
>> empty would work, but that would be two selection inversions in the
>> normal case and that may be a bit costly.
> The following appears to be about twice as fast as the two inversion approach.
>
> (let ((count (cdddr (gimp-histogram (car (gimp-image-get-selection image))
>   HISTOGRAM-VALUE
>   255
>   255
> (= (car count) (cadr count)) ; compare num of all pixels to all white 
> pixels
> )

Exactly what the doctor ordered. Thanks (and to Rob...). However, the 
only documentation I found of this function was in the API browser of 
the python-fu console. I couldn't find it in the files I sampled at 
. Where is it documented?

-- 
Bertrand


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Detecting "closure" of selection

2010-10-09 Thread saulgoode
Quoting Ofnuts :

> Is there a practical, fast way, to detect this case, i.e, that the
> selection covers the whole layer (or image?) and that no pixels remain
> unselected? I assume that inverting the selection again and testing for
> empty would work, but that would be two selection inversions in the
> normal case and that may be a bit costly.

The following appears to be about twice as fast as the two inversion approach.

(let ((count (cdddr (gimp-histogram (car (gimp-image-get-selection image))
 HISTOGRAM-VALUE
 255
 255
   (= (car count) (cadr count)) ; compare num of all pixels to all white pixels
   )



___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Detecting "closure" of selection

2010-10-09 Thread Rob Antonishen
Thinking off the top of my head, you could make a histogram call to
the selection "channel" at 255 (fully selected) and see if the
returned pixel count equals the number of pixels (width x height).



On 10/9/10, Ofnuts  wrote:
>   On 10/10/2010 00:22, David Gowers (kampu) wrote:
>> On Sun, Oct 10, 2010 at 7:47 AM, Ofnuts  wrote:
>>>   Assume I have a selection on small area (for instance a 20px circle),
>>> and I invert it. Now, if I grow the selection by a sufficient amount
>>> (10px in this case), everything gets selected.
>>>
>>> Is there a practical, fast way, to detect this case, i.e, that the
>>> selection covers the whole layer (or image?) and that no pixels remain
>>> unselected? I assume that inverting the selection again and testing for
>>> empty would work, but that would be two selection inversions in the
>>> normal case and that may be a bit costly.
>> Testing for empty and for full are the same operation (an empty sel is
>> equivalent to a full one)
>>
>> HTH
>>
>
> There are indeed many tools that behave the same way if the selection is
> empty of complete, but gimp_selection_is_empty
> ()
> return False when the selection is complete, alas.
>
>
> --
> Bertrand
>
>
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Detecting "closure" of selection

2010-10-09 Thread Ofnuts

 On 10/10/2010 00:22, David Gowers (kampu) wrote:

On Sun, Oct 10, 2010 at 7:47 AM, Ofnuts  wrote:

  Assume I have a selection on small area (for instance a 20px circle),
and I invert it. Now, if I grow the selection by a sufficient amount
(10px in this case), everything gets selected.

Is there a practical, fast way, to detect this case, i.e, that the
selection covers the whole layer (or image?) and that no pixels remain
unselected? I assume that inverting the selection again and testing for
empty would work, but that would be two selection inversions in the
normal case and that may be a bit costly.

Testing for empty and for full are the same operation (an empty sel is
equivalent to a full one)

HTH



There are indeed many tools that behave the same way if the selection is 
empty of complete, but gimp_selection_is_empty 
() 
return False when the selection is complete, alas.



--
Bertrand

___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Detecting "closure" of selection

2010-10-09 Thread David Gowers (kampu)
On Sun, Oct 10, 2010 at 7:47 AM, Ofnuts  wrote:
>  Assume I have a selection on small area (for instance a 20px circle),
> and I invert it. Now, if I grow the selection by a sufficient amount
> (10px in this case), everything gets selected.
>
> Is there a practical, fast way, to detect this case, i.e, that the
> selection covers the whole layer (or image?) and that no pixels remain
> unselected? I assume that inverting the selection again and testing for
> empty would work, but that would be two selection inversions in the
> normal case and that may be a bit costly.
Testing for empty and for full are the same operation (an empty sel is
equivalent to a full one)

HTH
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Detecting "closure" of selection

2010-10-09 Thread Ofnuts
  On 09/10/2010 23:24, Owen wrote:
>>Assume I have a selection on small area (for instance a 20px
>> circle),
>> and I invert it. Now, if I grow the selection by a sufficient amount
>> (10px in this case), everything gets selected.
>>
>> Is there a practical, fast way, to detect this case, i.e, that the
>> selection covers the whole layer (or image?) and that no pixels remain
>> unselected? I assume that inverting the selection again and testing
>> for
>> empty would work, but that would be two selection inversions in the
>> normal case and that may be a bit costly.
>
> Select->all?

I don't want to select all. I want to catch if a selection_grow() ended 
up selecting everything.

-- 
Bertrand


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Detecting "closure" of selection

2010-10-09 Thread Owen
>   Assume I have a selection on small area (for instance a 20px
> circle),
> and I invert it. Now, if I grow the selection by a sufficient amount
> (10px in this case), everything gets selected.
>
> Is there a practical, fast way, to detect this case, i.e, that the
> selection covers the whole layer (or image?) and that no pixels remain
> unselected? I assume that inverting the selection again and testing
> for
> empty would work, but that would be two selection inversions in the
> normal case and that may be a bit costly.



Select->all?


-- 

Owen

___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] Detecting "closure" of selection

2010-10-09 Thread Ofnuts
  Assume I have a selection on small area (for instance a 20px circle), 
and I invert it. Now, if I grow the selection by a sufficient amount 
(10px in this case), everything gets selected.

Is there a practical, fast way, to detect this case, i.e, that the 
selection covers the whole layer (or image?) and that no pixels remain 
unselected? I assume that inverting the selection again and testing for 
empty would work, but that would be two selection inversions in the 
normal case and that may be a bit costly.

-- 
Bertrand


___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer