Giter Club home page Giter Club logo

Comments (6)

ntustison avatar ntustison commented on August 30, 2024 1

One easy solution off the top of my head:

colorbarImage <- as.antsImage( rbind( 1:100, 1:100, 1:100, 1:100, 1:100, 1:100, 1:100, 1:100, 1:100, 1:100 ) )

from antsr.

stnava avatar stnava commented on August 30, 2024

yes -- the "plot a color bar" then add numbers on your own approach is good. antsSurf just uses standard color maps. you can google color bars for the standard maps and then amend those. @ntustison - do you agree?

from antsr.

ntustison avatar ntustison commented on August 30, 2024

Yeah, agreed. Whenever I need to make custom color bars, I create my own using convertScalarImageToRGB but, correct me if I'm wrong, I don't think that functionality is available in the ANTsR package.

from antsr.

stnava avatar stnava commented on August 30, 2024

pretty sure convertScalarImageToRGB is wrapped in some way within R ... I know it's called directly ... anyway this entire pipeline of functionality is very powerful but could be greatly improved -- probably a useful thing to target for our recent funding.

from antsr.

ptsii avatar ptsii commented on August 30, 2024

I see from calling convertScalarImageToRGB that it requires an input image. What's an easy way to create a 2D image that has, say, 10 pixels in the x dimension and 100 in the y dimension, with the y values going from 1 to 100? If I understand correctly, convertScalarImageToRGB would translate that into an appropriate colorbar matching the colormap I use?

from antsr.

ptsii avatar ptsii commented on August 30, 2024

Thank you for the hint! For future reference to anyone else needing the same thing, here is what I got to work:

  1. created two files in ANTsR, one the image to be colored, the other a mask, and wrote them to disk:
> colorbarImage <- as.antsImage( rbind( 100:1, 100:1, 100:1, 100:1, 100:1, 100:1, 100:1, 100:1, 100:1, 100:1  ) )
> antsImageWrite(colorbarImage,"colorbarImage.nii")
> colorbarImageMask <- makeImage( c(10,100),1)
> antsImageWrite(colorbarImageMask,"colorbarImageMask.nii")

NOTE: The ordering of numbers "100:1" in the rbind command above puts the highest values at the top of the image, and lowest values at the bottom, which is typically what you want for colorbar legends

  1. on the command line (outside of R), using ANTS' convertScalarImageToRGB:
    ConvertScalarImageToRGB 2 colorbarImage.nii colorbarImageJet.jpg colorbarImageMask.nii jet

This creates a jpg of a bar with the range of colors matching, in this case, the "jet" colormap. Reading this into whatever you use to create figures (e.g., powerpoint) allows you to add text indicating values for different parts of the range.

from antsr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.