0

Here's what I have so far:

from wand.image import Image
from wand.display import display
img=Image(filename='filename.ras')
display(img)

next I want to loop over a list of 2D indices and change the pixel color of each of these corresponding points in img to red. The color table of 'filename.ras' is entirely greyscale.

Probably an easy question, but since I can't find any tutorials on this I thought I might as well ask. Thanks.

zimzam
  • 81
  • 8

1 Answers1

0

I think below is the best solution for this problem that uses Wand:

from wand.image import Image
from wand.display import display
from wand.drawing import Drawing
from wand.color import Color
img=Image(filename='../../rmli_fr/rmli_fr.ave.ras')

color = Color('red')
draw = Drawing()
draw.fill_color = color
for i in pts_comp:
    draw.line((i[0], i[1]), (i[0], i[1]))
    draw(img)

img.save(filename='rmli.ras')

however it is extremely slow and it increases the number of colors in the original color table so that if you are in 24-bit mode all the colored pixels come out with the 0th value in your color table. Therefore, I think the better solution for working with sun raster files is not to use Wand, but instead manipulate the data directly treating the file as an array of bytes with a header and a color table.

zimzam
  • 81
  • 8