Adjusting brightness and contrast programmatically for the BigDataViewer

Hi @tpietzsch @hanslovsky,

After seeing some examples online and the javadocs, I thought this is how I could adjust the brightness and contrast from a script in the BigDataViewer:

from bdv.util import BdvFunctions, Bdv
from bdv.tools import InitializeViewerState

bdv = BdvFunctions.show(cachedCellImg, "4D volume")
print bdv.getBdvHandle()
InitializeViewerState.initBrightness(16, 510, bdv.getBdvHandle().getBigDataViewer().getViewerFrame())

But when I run it, the BigDataViewer still shows the default brightness and contrast (the whole 16-bit range).

Am I missing something?

Thanks,
Albert

I’ve never heard about InitializeViewerState, but this should work:

        BdvStackSource bss = BdvFunctions.show(cachedCellImg, "4D volume");
        bss.setDisplayRange(16,510);
        bss.setColor(new ARGBType(ARGBType.rgba(255,255,255,255))); // To change the color
2 Likes