bigdataviewer / bigdataviewer-core

ImgLib2-based viewer for registered SPIM stacks and more
BSD 2-Clause "Simplified" License
33 stars 35 forks source link

Show SourceAndConverter #189

Open tischi opened 4 years ago

tischi commented 4 years ago

@tpietzsch @NicoKiaru I am trying to implement BdvFunctions.show( SourceAndConverter ). At some point the code arrives here in bdv-core: https://github.com/bigdataviewer/bigdataviewer-core/blob/6d32df2f4fa849fdbd4b1ad9251a08376e3c82ab/src/main/java/bdv/BigDataViewer.java#L212 where only ColorConverter are accepted. I understand that for the current UI this is nice to have, but I guess, in principle, it would also be OK to have an arbitrary Converter< ?, ARGBType >. What do you think?

[EDIT] Maybe it in fact does make sense to only accept ColorConverter because otherwise one cannot adjust brightness and contrast. If we want to implement this in a clean way we should then maybe have a new class called SourceAndColorConverter? And only allow this one to be shown in the bdv?

cc @hanslovsky

NicoKiaru commented 4 years ago

Tobias explained in gitter something about a 'ConverterSetup' class which could specify what can be set in bdv (min/max and optionnally a color) ? Isn't this related?

tischi commented 4 years ago

Yes, this is related. I think currently a ConverterSetup only makes sense for a ColorConverter.

tischi commented 4 years ago

Another thing we could do for cases where the provided Converter is not a ColorConverter is implement a wrapper, e.g. something like this

public static class ARGBConverter extends ScaledARGBConverter< ARGBType >
{          
        Converter< ?, ARGBType > converter

        public ARGB( final Converter< ?, ARGBType > converter, final double min, final double max )
    {
               this.converter = converter;
           super( min, max );
    }

    @Override
    public void convert( final ? input, final ARGBType output )
    {
               converter.convert( input, output );
           output.set( getScaledColor( output.get() ) );
    }
}