Java Code Examples for java.awt.image.BufferedImage.TYPE_USHORT_GRAY

The following are Jave code examples for showing how to use TYPE_USHORT_GRAY of the java.awt.image.BufferedImage class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: sumo   File: GeotiffImage.java   View Source Code Vote up 6 votes
@Override
public int getType(boolean oneBand) {
    int nBand = getNBand();
    if (oneBand | nBand == 1) {
        //if (td.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS).getAsInt(0) == 1) {
        //    return BufferedImage.TYPE_BYTE_GRAY;
        //} else if (td.getTIFFField(BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS).getAsInt(0) == 2) {
        return BufferedImage.TYPE_USHORT_GRAY;
        //}
    } else if (nBand == 2) {
        return BufferedImage.TYPE_BYTE_GRAY;
    } else if (nBand == 3) {
        return BufferedImage.TYPE_INT_RGB;
    } else if (nBand == 4) {
        return BufferedImage.TYPE_INT_RGB;
    }
    return BufferedImage.TYPE_BYTE_GRAY;
}
 
Example 2
Project: sumo   File: GeoImageUtils.java   View Source Code Vote up 6 votes
/**
 * create a quicklook image from the GeoImageReader
 * @param gir the source image
 * @param width the output width
 * @param height the output height
 * @return a BufferedImage representing the quicklook
 */
public static BufferedImage createOverview(GeoImageReader gir, int width, int height,int band){
    int nPass=gir.getHeight()/Constant.GEOIMAGE_TILE_SIZE;
    int xstep=gir.getWidth()/width;
    int ystep=gir.getHeight()/height;
    width=gir.getWidth()/xstep;
    height= gir.getHeight()/ystep;
    BufferedImage out=new BufferedImage(width,height, BufferedImage.TYPE_USHORT_GRAY);
    WritableRaster raster=out.getRaster();
    for(int i=0;i<nPass;i++){
        int[] t=gir.readTile(0, i*Constant.GEOIMAGE_TILE_SIZE, gir.getWidth(), Constant.GEOIMAGE_TILE_SIZE,band);
        for(int x=0;x<width;x++){
            for(int y=i*height/nPass;y<(i+1)*height/nPass;y++){
                raster.setSample(x, y, 0, t[x*xstep*(y-i*height/nPass)*ystep]);
            }
        }
    }
    return out;
}
 
Example 3
Project: sumo   File: TerrasarXImage.java   View Source Code Vote up 6 votes
@Override
public int getType(boolean oneBand) {
    int nBand = getNBand();
    /*if (oneBand | nBand == 1) {
        return BufferedImage.TYPE_USHORT_GRAY;
    } else if (nBand == 2) {
        return BufferedImage.TYPE_BYTE_GRAY;
    } else if (nBand == 3) {
        return BufferedImage.TYPE_INT_RGB;
    } else if (nBand == 4) {
        return BufferedImage.TYPE_INT_ARGB;
    }

    return BufferedImage.TYPE_USHORT_GRAY;*/
    if(oneBand || bands.size()<2) return BufferedImage.TYPE_USHORT_GRAY;
    else return BufferedImage.TYPE_INT_RGB;
}
 
Example 4
Project: openjdk-jdk10   File: ColConvTest.java   View Source Code Vote up 6 votes
static String getImageTypeName(int type) {
    switch(type) {
        case BufferedImage.TYPE_INT_ARGB:
            return "TYPE_INT_ARGB";
        case BufferedImage.TYPE_INT_RGB:
            return "TYPE_INT_RGB";
        case BufferedImage.TYPE_INT_BGR:
            return "TYPE_INT_BGR";
        case BufferedImage.TYPE_INT_ARGB_PRE:
            return "TYPE_INT_ARGB_PRE";
        case BufferedImage.TYPE_3BYTE_BGR:
            return "TYPE_3BYTE_BGR";
        case BufferedImage.TYPE_4BYTE_ABGR:
            return "TYPE_4BYTE_ABGR";
        case BufferedImage.TYPE_4BYTE_ABGR_PRE:
            return "TYPE_4BYTE_ABGR_PRE";
        case BufferedImage.TYPE_BYTE_BINARY:
            return "TYPE_BYTE_BINARY";
        case BufferedImage.TYPE_BYTE_GRAY:
            return "TYPE_BYTE_GRAY";
        case BufferedImage.TYPE_BYTE_INDEXED:
            return "TYPE_BYTE_INDEXED";
        case BufferedImage.TYPE_USHORT_555_RGB:
            return "TYPE_USHORT_555_RGB";
        case BufferedImage.TYPE_USHORT_565_RGB:
            return "TYPE_USHORT_565_RGB";
        case BufferedImage.TYPE_USHORT_GRAY:
            return "TYPE_USHORT_GRAY";
    }
    return "UNKNOWN";
}
 
Example 5
Project: sumo   File: GDALAlosCeos.java   View Source Code Vote up 5 votes
@Override
public int getType(boolean oneBand) {
	if (oneBand || polarizations.size() < 2)
		return BufferedImage.TYPE_USHORT_GRAY;
	else
		return BufferedImage.TYPE_INT_RGB;
}
 
Example 6
Project: sumo   File: BinaryAlosCeos.java   View Source Code Vote up 5 votes
@Override
public int getType(boolean oneBand) {
	if (oneBand || polarizations.size() < 2)
		return BufferedImage.TYPE_USHORT_GRAY;
	else
		return BufferedImage.TYPE_INT_RGB;
}
 
Example 7
Project: sumo   File: Radarsat2Image_SLC.java   View Source Code Vote up 5 votes
@Override
public int getType(boolean oneBand) {
    if (oneBand || bands.length < 2) {
        return BufferedImage.TYPE_USHORT_GRAY;
    } else {
        return BufferedImage.TYPE_INT_RGB;
    }
}
 
Example 8
Project: sumo   File: Radarsat1Image.java   View Source Code Vote up 5 votes
@Override
public int getType(boolean oneBand) {
    //only one band
    if (numberOfBytes == 1) {
        return BufferedImage.TYPE_BYTE_GRAY;
    } else {
        return BufferedImage.TYPE_USHORT_GRAY;
    }
}
 
Example 9
Project: sumo   File: Radarsat2Image_SLCGDAL.java   View Source Code Vote up 5 votes
@Override
public int getType(boolean oneBand) {
    ////if (oneBand || bands.length < 2) {
        return BufferedImage.TYPE_USHORT_GRAY;
    //} else {
    //    return BufferedImage.TYPE_INT_RGB;
    //}
}
 
Example 10
Project: jdk8u-jdk   File: ColConvTest.java   View Source Code Vote up 5 votes
static String getImageTypeName(int type) {
    switch(type) {
        case BufferedImage.TYPE_INT_ARGB:
            return "TYPE_INT_ARGB";
        case BufferedImage.TYPE_INT_RGB:
            return "TYPE_INT_RGB";
        case BufferedImage.TYPE_INT_BGR:
            return "TYPE_INT_BGR";
        case BufferedImage.TYPE_INT_ARGB_PRE:
            return "TYPE_INT_ARGB_PRE";
        case BufferedImage.TYPE_3BYTE_BGR:
            return "TYPE_3BYTE_BGR";
        case BufferedImage.TYPE_4BYTE_ABGR:
            return "TYPE_4BYTE_ABGR";
        case BufferedImage.TYPE_4BYTE_ABGR_PRE:
            return "TYPE_4BYTE_ABGR_PRE";
        case BufferedImage.TYPE_BYTE_BINARY:
            return "TYPE_BYTE_BINARY";
        case BufferedImage.TYPE_BYTE_GRAY:
            return "TYPE_BYTE_GRAY";
        case BufferedImage.TYPE_BYTE_INDEXED:
            return "TYPE_BYTE_INDEXED";
        case BufferedImage.TYPE_USHORT_555_RGB:
            return "TYPE_USHORT_555_RGB";
        case BufferedImage.TYPE_USHORT_565_RGB:
            return "TYPE_USHORT_565_RGB";
        case BufferedImage.TYPE_USHORT_GRAY:
            return "TYPE_USHORT_GRAY";
    }
    return "UNKNOWN";
}
 
Example 11
Project: sumo   File: Sentinel1.java   View Source Code Vote up 4 votes
@Override
public int getType(boolean oneBand) {
    if(oneBand || polarizations.size()<2) return BufferedImage.TYPE_USHORT_GRAY;
    else return BufferedImage.TYPE_INT_RGB;
}
 
Example 12
Project: sumo   File: EnvisatImage.java   View Source Code Vote up 4 votes
@Override
public int getType(boolean oneBand) {
    return BufferedImage.TYPE_USHORT_GRAY;
}
 
Example 13
Project: sumo   File: Alos.java   View Source Code Vote up 4 votes
@Override
public int getType(boolean oneBand) {
	if(oneBand || polarizations.size()<2) return BufferedImage.TYPE_USHORT_GRAY;
       else return BufferedImage.TYPE_INT_RGB;
}
 
Example 14
Project: sumo   File: AlosGeoTiff.java   View Source Code Vote up 4 votes
@Override
public int getType(boolean oneBand) {
	if(oneBand || polarizations.size()<2) return BufferedImage.TYPE_USHORT_GRAY;
       else return BufferedImage.TYPE_INT_RGB;
}
 
Example 15
Project: sumo   File: Radarsat2Image.java   View Source Code Vote up 4 votes
@Override
public int getType(boolean oneBand) {
    if(oneBand || bands.length<2) return BufferedImage.TYPE_USHORT_GRAY;
    else return BufferedImage.TYPE_INT_RGB;
}
 
Example 16
Project: sumo   File: AbstractCosmoSkymedImage.java   View Source Code Vote up 4 votes
public int getType(boolean oneBand) {
    return BufferedImage.TYPE_USHORT_GRAY;
}
 
Example 17
Project: OpenJSharp   File: PixelTests.java   View Source Code Vote up 4 votes
public static void init() {
    pixelroot = new Group("pixel", "Pixel Access Benchmarks");

    pixeloptroot = new Group(pixelroot, "opts", "Pixel Access Options");
    doRenderTo = new Option.Toggle(pixeloptroot, "renderto",
                                   "Render to Image before test",
                                   Option.Toggle.Off);
    doRenderFrom = new Option.Toggle(pixeloptroot, "renderfrom",
                                     "Render from Image before test",
                                     Option.Toggle.Off);

    // BufferedImage Sources
    bufimgsrcroot = new Group.EnableSet(pixelroot, "src",
                                        "BufferedImage Sources");
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 1);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 2);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 4);
    new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
    new BufImg(BufferedImage.TYPE_BYTE_GRAY);
    new BufImg(BufferedImage.TYPE_USHORT_555_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_565_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_GRAY);
    new BufImg(BufferedImage.TYPE_3BYTE_BGR);
    new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
    new BufImg(BufferedImage.TYPE_INT_RGB);
    new BufImg(BufferedImage.TYPE_INT_BGR);
    new BufImg(BufferedImage.TYPE_INT_ARGB);

    // BufferedImage Tests
    bufimgtestroot = new Group(pixelroot, "bimgtests",
                               "BufferedImage Tests");
    new BufImgTest.GetRGB();
    new BufImgTest.SetRGB();

    // Raster Tests
    rastertestroot = new Group(pixelroot, "rastests",
                               "Raster Tests");
    new RasTest.GetDataElements();
    new RasTest.SetDataElements();
    new RasTest.GetPixel();
    new RasTest.SetPixel();

    // DataBuffer Tests
    dbtestroot = new Group(pixelroot, "dbtests",
                           "DataBuffer Tests");
    new DataBufTest.GetElem();
    new DataBufTest.SetElem();
}
 
Example 18
Project: jdk8u-jdk   File: PixelTests.java   View Source Code Vote up 4 votes
public static void init() {
    pixelroot = new Group("pixel", "Pixel Access Benchmarks");

    pixeloptroot = new Group(pixelroot, "opts", "Pixel Access Options");
    doRenderTo = new Option.Toggle(pixeloptroot, "renderto",
                                   "Render to Image before test",
                                   Option.Toggle.Off);
    doRenderFrom = new Option.Toggle(pixeloptroot, "renderfrom",
                                     "Render from Image before test",
                                     Option.Toggle.Off);

    // BufferedImage Sources
    bufimgsrcroot = new Group.EnableSet(pixelroot, "src",
                                        "BufferedImage Sources");
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 1);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 2);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 4);
    new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
    new BufImg(BufferedImage.TYPE_BYTE_GRAY);
    new BufImg(BufferedImage.TYPE_USHORT_555_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_565_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_GRAY);
    new BufImg(BufferedImage.TYPE_3BYTE_BGR);
    new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
    new BufImg(BufferedImage.TYPE_INT_RGB);
    new BufImg(BufferedImage.TYPE_INT_BGR);
    new BufImg(BufferedImage.TYPE_INT_ARGB);

    // BufferedImage Tests
    bufimgtestroot = new Group(pixelroot, "bimgtests",
                               "BufferedImage Tests");
    new BufImgTest.GetRGB();
    new BufImgTest.SetRGB();

    // Raster Tests
    rastertestroot = new Group(pixelroot, "rastests",
                               "Raster Tests");
    new RasTest.GetDataElements();
    new RasTest.SetDataElements();
    new RasTest.GetPixel();
    new RasTest.SetPixel();

    // DataBuffer Tests
    dbtestroot = new Group(pixelroot, "dbtests",
                           "DataBuffer Tests");
    new DataBufTest.GetElem();
    new DataBufTest.SetElem();
}
 
Example 19
Project: openjdk-jdk10   File: PixelTests.java   View Source Code Vote up 4 votes
public static void init() {
    pixelroot = new Group("pixel", "Pixel Access Benchmarks");

    pixeloptroot = new Group(pixelroot, "opts", "Pixel Access Options");
    doRenderTo = new Option.Toggle(pixeloptroot, "renderto",
                                   "Render to Image before test",
                                   Option.Toggle.Off);
    doRenderFrom = new Option.Toggle(pixeloptroot, "renderfrom",
                                     "Render from Image before test",
                                     Option.Toggle.Off);

    // BufferedImage Sources
    bufimgsrcroot = new Group.EnableSet(pixelroot, "src",
                                        "BufferedImage Sources");
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 1);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 2);
    new BufImg(BufferedImage.TYPE_BYTE_BINARY, 4);
    new BufImg(BufferedImage.TYPE_BYTE_INDEXED);
    new BufImg(BufferedImage.TYPE_BYTE_GRAY);
    new BufImg(BufferedImage.TYPE_USHORT_555_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_565_RGB);
    new BufImg(BufferedImage.TYPE_USHORT_GRAY);
    new BufImg(BufferedImage.TYPE_3BYTE_BGR);
    new BufImg(BufferedImage.TYPE_4BYTE_ABGR);
    new BufImg(BufferedImage.TYPE_INT_RGB);
    new BufImg(BufferedImage.TYPE_INT_BGR);
    new BufImg(BufferedImage.TYPE_INT_ARGB);

    // BufferedImage Tests
    bufimgtestroot = new Group(pixelroot, "bimgtests",
                               "BufferedImage Tests");
    new BufImgTest.GetRGB();
    new BufImgTest.SetRGB();

    // Raster Tests
    rastertestroot = new Group(pixelroot, "rastests",
                               "Raster Tests");
    new RasTest.GetDataElements();
    new RasTest.SetDataElements();
    new RasTest.GetPixel();
    new RasTest.SetPixel();

    // DataBuffer Tests
    dbtestroot = new Group(pixelroot, "dbtests",
                           "DataBuffer Tests");
    new DataBufTest.GetElem();
    new DataBufTest.SetElem();
}
 
Example 20
Project: openjdk-jdk10   File: UshortOutOfMemoryTest.java   View Source Code Vote up 4 votes
public static void main(String[] args) throws IOException {
    UshortOutOfMemoryTest t = new UshortOutOfMemoryTest(
            BufferedImage.TYPE_USHORT_GRAY);
    t.testGetAsTree();
}