Re: [Gimp-developer] Script-fu primitive wishlist: islands, integrals/sums, and data files

2008-11-01 Thread saulgoode
Quoting Adam C Powell IV <[EMAIL PROTECTED]>:

> I don't suppose there's a script-fu interface to the file browser for
> setting the file name...

The registration parameters (SF-FILE) get evaluated when Script-fu is  
loaded (or scripts are "Refreshed") and dialog boxes for file browsing  
otherwise use the "last values" with which the function was invoked.  
(In other words, I don't believe it possible to set the filename.)

> Thanks, got it working.  And Saul, text is all I need, can't speak for
> others.

I don't think that Script-fu needs the functionality to access binary  
files (nor that 'read-byte' and 'write-byte' would be the best  
approach); however, it does seem that the TinyScheme interpreter  
should provide such support.

> One more question: I can't seem to access procedures in my scripts from
> the console.  That is, if I define some procedures in files
> in .gimp-2.4/scripts/foo, the console doesn't know they exist.  Is there
> a way to access those procedures from the console?

Filenames in the 'scripts' folder must have the extension ".scm" or  
they are ignored by Script-fu. If you rename your file to "foo.scm",  
all functions defined within it should be available in the console.

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


Re: [Gimp-developer] Script-fu primitive wishlist: islands, integrals/sums, and data files

2008-11-01 Thread Adam C Powell IV
On Fri, 2008-10-31 at 19:27 -0400, Kevin Cozens wrote:
> David Gowers wrote:
> >> One is finding "islands" in an image
> [snip]
> >> Another is integrals: zero, first and second moments, or alternatively,
> >> integrals/sums of channel intensity, x- and y-weighted intensity, and
> >> x^2, y^2 and xy-weighted intensity.
> 
> As you stated, the above two features could be implemented in Scheme but they 
> would probably be too slow in actual use.

Indeed, just tried, they're quite slow.  When I can't bear it any
longer, I'll see about a C plugin.

> >> Finally, opening and storing data files.
> 
> See section 6.6 of the R5RS. Working with external files is handled via the 
> use of pipes.

Thanks, got it working.  And Saul, text is all I need, can't speak for
others.

I don't suppose there's a script-fu interface to the file browser for
setting the file name...

One more question: I can't seem to access procedures in my scripts from
the console.  That is, if I define some procedures in files
in .gimp-2.4/scripts/foo, the console doesn't know they exist.  Is there
a way to access those procedures from the console?

Cheers,
-Adam
-- 
GPG fingerprint: D54D 1AEE B11C CE9B A02B  C5DD 526F 01E8 564E E4B6

Engineering consulting with open source tools
http://www.opennovation.com/


signature.asc
Description: This is a digitally signed message part
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Script-fu primitive wishlist: islands, integrals/sums, and data files

2008-10-31 Thread saulgoode
Quoting Kevin Cozens <[EMAIL PROTECTED]>:

>>> Finally, opening and storing data files.
>
> See section 6.6 of the R5RS. Working with external files is handled via the
> use of pipes.
>

A problem which I encountered with TinyScheme's character I/O is that  
the 'read-char' and 'write-char' functions perform UNICODE  
conversions, making it impossible to read and write "binary" data  
files. The R5RS specification doesn't seem to address this but the  
TinyScheme implementation does seem to cripple the ability to read and  
write non-text files.

I had added a 'read-byte' command to my personal GIMP-2-4 [1] (I never  
got around to implementing 'write-byte') and would be happy to  
contribute patches to add such capability, if deemed appropriate/useful.



[1] http://flashingtwelve.brickfilms.com/GIMP/Temp/read-byte.diff.gz



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


Re: [Gimp-developer] Script-fu primitive wishlist: islands, integrals/sums, and data files

2008-10-31 Thread Kevin Cozens
David Gowers wrote:
>> One is finding "islands" in an image
[snip]
>> Another is integrals: zero, first and second moments, or alternatively,
>> integrals/sums of channel intensity, x- and y-weighted intensity, and
>> x^2, y^2 and xy-weighted intensity.

As you stated, the above two features could be implemented in Scheme but they 
would probably be too slow in actual use.

>> Finally, opening and storing data files.

See section 6.6 of the R5RS. Working with external files is handled via the 
use of pipes.

>> If there are other packages which can do this, that would be helpful.

A C based plug-in or a Python based script are probably better bets for the 
first two items.

-- 
Cheers!

Kevin.

http://www.ve3syb.ca/   |"What are we going to do today, Borg?"
Owner of Elecraft K2 #2172  |"Same thing we always do, Pinkutus:
 |  Try to assimilate the world!"
#include  |  -Pinkutus & the Borg
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Script-fu primitive wishlist: islands, integrals/sums, and data files

2008-10-31 Thread Adam C Powell IV
On Sat, 2008-11-01 at 01:02 +1030, David Gowers wrote:
> Hi Adam,
> 
> On Fri, Oct 31, 2008 at 9:51 PM, Adam C Powell IV <[EMAIL PROTECTED]> wrote:
> > Greetings,
> >
> > I am working on an image processing plug-in (which I'll offer for
> > upstream contribution BSD-licensed), and would really like to have a
> > couple of primitives that I can't find.
> >
> > One is finding "islands" in an image: take a channel and create new
> > layers each with one contiguous region in the channel.  So if the
> > channel has ten islands, create ten new layers, each with one of the
> > islands.  Since this could be unwieldy (too many new layers), one new
> > layer with one island would suffice; one could then process that island
> > layer, subtract it from the original, and move on.
> >
> > Another is integrals: zero, first and second moments, or alternatively,
> > integrals/sums of channel intensity, x- and y-weighted intensity, and
> > x^2, y^2 and xy-weighted intensity.  This lets me fit an ellipse to an
> > island, and then display major and minor axes.
> >
> > Finally, opening and storing data files.  I'd like to be able to create
> > a CSV file with statistics of the islands: size, centroid, aspect ratio
> > (major/minor axis ratio), major axis orientation.  One could then
> > further process these statistics in a spreadsheet or other program.
> >
> > I can do the first two in scheme, though it would be slow, but tolerable
> > for my needs.  I don't see a script-fu primitive which would let me do
> > the last.
> >
> > If there are other packages which can do this, that would be helpful.
> > But having it in the same program/UI as GIMP, with all of its other
> > image manipulation tools, and with its presence across platforms, would
> > be even better.  I'd love to have your ideas.
> 
> It sounds like you might find working with the combination of
> Gimp-Python, NumPy and SciPy more effective.
> integration,definitely. Islands, possibly (a browse through
> http://scipy.org/scipy/scipy/browser/trunk might help you to find out.
> And Python has a CSV module as standard.

Okay, thanks for the suggestion.  The downsides seem to be: I and others
need to install these as well as GIMP to use it, I need to learn Python
(yes, I'm one of the tiny handful remaining who know scheme but not
python :-), and converting from a GIMP image to something which
NumPy/SciPy can quickly sum might not be straightforward.

> I had the impression that writing external files was not supported by
> Script-Fu; I'm sure Kevin Cozens could tell you.

Okay, I look forward to hearing from him.  Hmm, I suppose if the output
is small enough, this could return it as a list, and one could run it in
the script-fu console then copy-and-paste the return value...

> Hope that helps,

Yes, thanks much.

-Adam
-- 
GPG fingerprint: D54D 1AEE B11C CE9B A02B  C5DD 526F 01E8 564E E4B6

Engineering consulting with open source tools
http://www.opennovation.com/


signature.asc
Description: This is a digitally signed message part
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Script-fu primitive wishlist: islands, integrals/sums, and data files

2008-10-31 Thread David Gowers
Hi Adam,

On Fri, Oct 31, 2008 at 9:51 PM, Adam C Powell IV <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I am working on an image processing plug-in (which I'll offer for
> upstream contribution BSD-licensed), and would really like to have a
> couple of primitives that I can't find.
>
> One is finding "islands" in an image: take a channel and create new
> layers each with one contiguous region in the channel.  So if the
> channel has ten islands, create ten new layers, each with one of the
> islands.  Since this could be unwieldy (too many new layers), one new
> layer with one island would suffice; one could then process that island
> layer, subtract it from the original, and move on.
>
> Another is integrals: zero, first and second moments, or alternatively,
> integrals/sums of channel intensity, x- and y-weighted intensity, and
> x^2, y^2 and xy-weighted intensity.  This lets me fit an ellipse to an
> island, and then display major and minor axes.
>
> Finally, opening and storing data files.  I'd like to be able to create
> a CSV file with statistics of the islands: size, centroid, aspect ratio
> (major/minor axis ratio), major axis orientation.  One could then
> further process these statistics in a spreadsheet or other program.
>
> I can do the first two in scheme, though it would be slow, but tolerable
> for my needs.  I don't see a script-fu primitive which would let me do
> the last.
>
> If there are other packages which can do this, that would be helpful.
> But having it in the same program/UI as GIMP, with all of its other
> image manipulation tools, and with its presence across platforms, would
> be even better.  I'd love to have your ideas.

It sounds like you might find working with the combination of
Gimp-Python, NumPy and SciPy more effective.
integration,definitely. Islands, possibly (a browse through
http://scipy.org/scipy/scipy/browser/trunk might help you to find out.
And Python has a CSV module as standard.

I had the impression that writing external files was not supported by
Script-Fu; I'm sure Kevin Cozens could tell you.

Hope that helps,
David
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer