[Gimp-developer] /Filters/Render/Stroke to SVG...

2008-09-25 Thread paul taney


 
 When it doesn't register, is there any console output
 from GIMP?
 
 Chris


Ive got things working now and use numpy to convert bluelines to SVG lines or 
a python tuple that gets written out.

It could be of general interest for vectorizing if it treated a selection.  

But I am converting scanned stripcharts, and the ink is blue...  One y per x is 
all I need, and there would be a slick way to do that with numpy; Im just 
using a stride for line thinning.


The part I dont understand is this; I pass my bluemask to (Fremlins) 
write_out(drawable, image) as the image, it fails the assertion and does not 
post...

numpy.array((image*256).round(0),B)


def write_out(drawable, image):
by John Fremlin
byte_image = numpy.array((image*256).round(0),B)  # B is a ubyte
width = drawable.width
height = drawable.height
bpp = drawable.bpp
sys.stderr.write(write_out::drawable.width=%i drawable.height=%i 
drawable.bpp=%i\n % (width, height, bpp))

pr = drawable.get_pixel_rgn(0, 0, width, height, True)
assert(byte_image.size == width * height * bpp)
pr[:,:] = byte_image.tostring()



stroke_to_vector.py
Description: Binary data
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] /Filters/Render/Stroke to SVG...

2008-09-25 Thread David Gowers
Hi Paul,

On Fri, Sep 26, 2008 at 2:19 AM, paul taney [EMAIL PROTECTED] wrote:



 When it doesn't register, is there any console output
 from GIMP?

 Chris


 Ive got things working now and use numpy to convert bluelines to SVG lines 
 or a python tuple that gets written out.

 It could be of general interest for vectorizing if it treated a selection.

 But I am converting scanned stripcharts, and the ink is blue...  One y per x 
 is all I need, and there would be a slick way to do that with numpy; Im just 
 using a stride for line thinning.


 The part I dont understand is this; I pass my bluemask to (Fremlins) 
 write_out(drawable, image) as the image, it fails the assertion and does not 
 post...

numpy.array((image*256).round(0),B)

Which assertion fails?



 def write_out(drawable, image):
by John Fremlin
byte_image = numpy.array((image*256).round(0),B)  # B is a ubyte
width = drawable.width
height = drawable.height
bpp = drawable.bpp
sys.stderr.write(write_out::drawable.width=%i drawable.height=%i 
 drawable.bpp=%i\n % (width, height, bpp))

pr = drawable.get_pixel_rgn(0, 0, width, height, True)
assert(byte_image.size == width * height * bpp)
pr[:,:] = byte_image.tostring()

You are passing an RGB array to this function. Are you certain that
your destination drawable does not have an alpha channel (thus
requiring you to pass an RGBA array)?



David

-- 
Everything has reasons. Nothing has justification.
Ĉio havas kialojn; Neniaĵo havas pravigeron.
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] /Filters/Render/Stroke to SVG...

2008-09-25 Thread paul taney

--- On Thu, 9/25/08, David Gowers [EMAIL PROTECTED] wrote:

 From: David Gowers [EMAIL PROTECTED]

 Hi Paul,
 
 On Fri, Sep 26, 2008 at 2:19 AM, paul taney
 [EMAIL PROTECTED] wrote:
 
 
 
  When it doesn't register, is there any console
 output
  from GIMP?
 
  Chris
 
 
  Ive got things working now and use numpy to
 convert bluelines to SVG lines or a python tuple that gets
 written out.
 
  It could be of general interest for vectorizing if it
 treated a selection.
 
  But I am converting scanned stripcharts, and the ink
 is blue...  One y per x is all I need, and there would be a
 slick way to do that with numpy; Im just using a
 stride for line thinning.
 
 
  The part I dont understand is this; I pass my bluemask
 to (Fremlins) write_out(drawable, image) as the image,
 it fails the assertion and does not post...
 
 numpy.array((image*256).round(0),B)

Why does he multiply the image by 256 and elsewhere divide image/256?

 
 Which assertion fails?

Line 207:  assert(byte_image.size == width * height * bpp)
fails, right before the blit.

 
 
  def write_out(drawable, image):
 by John Fremlin
 byte_image =
 numpy.array((image*256).round(0),B)  # B is a
 ubyte
 width = drawable.width
 height = drawable.height
 bpp = drawable.bpp
 sys.stderr.write(write_out::drawable.width=%i
 drawable.height=%i drawable.bpp=%i\n % (width,
 height, bpp))
 
 pr = drawable.get_pixel_rgn(0, 0, width, height,
 True)
 assert(byte_image.size == width * height * bpp)
 pr[:,:] = byte_image.tostring()  # blit
 
 You are passing an RGB array to this function. Are you
 certain that
 your destination drawable does not have an alpha channel
 (thus requiring you to pass an RGBA array)?
 

I have added a test for that, as best I know how;  but it 
still fails at 207.

if drawable.has_alpha:
img = gimp.Image(width, height, RGBA_IMAGE)
new_layer = gimp.Layer(img, new_layer_name, width, height, 
   RGBA_IMAGE, opacity, NORMAL_MODE)
else:
img = gimp.Image(width, height, RGB_IMAGE)
new_layer = gimp.Layer(img, new_layer_name, width, height, 
   RGB_IMAGE, opacity, NORMAL_MODE)



stroke_to_vector.py
Description: Binary data
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] /Filters/Render/Stroke to SVG...

2008-09-25 Thread David Gowers
Hi Paul.

On Fri, Sep 26, 2008 at 8:56 AM, paul taney [EMAIL PROTECTED] wrote:
 Why does he multiply the image by 256 and elsewhere divide image/256?
He's expecting an image with values ranging 0..1. If the values you
are providing are 0..255, you'll need to remove both of those.


 Which assertion fails?

 Line 207:  assert(byte_image.size == width * height * bpp)
 fails, right before the blit.

 
 
  def write_out(drawable, image):
 by John Fremlin
 byte_image =
 numpy.array((image*256).round(0),B)  # B is a
 ubyte
 width = drawable.width
 height = drawable.height
 bpp = drawable.bpp
 sys.stderr.write(write_out::drawable.width=%i
 drawable.height=%i drawable.bpp=%i\n % (width,
 height, bpp))
 
 pr = drawable.get_pixel_rgn(0, 0, width, height,
 True)
 assert(byte_image.size == width * height * bpp)
 pr[:,:] = byte_image.tostring()  # blit

 You are passing an RGB array to this function. Are you
 certain that
 your destination drawable does not have an alpha channel
 (thus requiring you to pass an RGBA array)?


 I have added a test for that, as best I know how;  but it
 still fails at 207.

if drawable.has_alpha:
img = gimp.Image(width, height, RGBA_IMAGE)
new_layer = gimp.Layer(img, new_layer_name, width, height,
   RGBA_IMAGE, opacity, NORMAL_MODE)
else:
img = gimp.Image(width, height, RGB_IMAGE)
new_layer = gimp.Layer(img, new_layer_name, width, height,
   RGB_IMAGE, opacity, NORMAL_MODE)



This will not necessarily help, because your vanderwalt() routine is
still producing an RGB image always.

David

-- 
Everything has reasons. Nothing has justification.
Ĉio havas kialojn; Neniaĵo havas pravigeron.
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer