Login  Register

stand-alone image composition

Posted by Anthony Krinsky on Feb 21, 2008; 7:53pm
URL: http://imagej.273.s1.nabble.com/Pause-in-a-java-plugin-program-tp3697005p3697018.html

I'm trying to create a heatmap like this:
http://www.heatmapapi.com/Example_1.aspx

Can ij.jar be used outside of the tool to compose a base image with an
overlay, at a specific XY, using the MULTIPLY option?

//create base image 500x500 pixels
//colorize png spot
//overlay png spot at 20,20; 50,50; etc. using ComposeMultiply
//write out composed image

Would anyone be able to provide short snippet?  The code below is the
same for doing it in Ruby using the Image Magick library.

Thank you in advance!

Anthony



file.geturls.each do |url|
  puts "Parsing clicks for #{url}\n"
  pagedata = file.coordsurl(url)

  # Create click-dot, colorized
  intensity = (100-(100/pagedata.reps))/100.to_f
*    click_image =
Magick::Image.read(conf.data['dotimage']).first.colorize(intensity,intensity,intensity,'white')    
*

  # Create overlay image
  halfwidth=conf.data['dotwidth']/2      image =
Magick::Image.new(pagedata.x+halfwidth, pagedata.y+halfwidth) {
self.background_color = 'gray100' }
    # Add click dots
  i = 0
  pagedata.list.each do |coords|
    i = i+1
*      
image.composite!(click_image,coords.x-halfwidth,coords.y-halfwidth,
Magick::MultiplyCompositeOp)*
  end
  puts "clicks composed"
  image.negate.write("#{url}map.png")
    # Haven't figured out how to do the following with RMagick yet:
  system("convert #{url}map.png -type TruecolorMatte
#{conf.data['colorimage']} -fx \"v.p{0,u*v.h}\" #{url}map.png")
  system("convert #{url}map.png -channel A -fx
\"A*#{conf.data['opacity']}\" #{url}map.png")
  puts "Done with #{url}map.png\n"

end