Using the Java 2D ColorConvertOp and RescaleOp Filter Classes to Process Images Los Angeles CA

Learn how to write programs that use the RescaleOp and ColorConvertOp classes of the Java 2D API to perform a variety of filtering operations on images.

Local Companies

Moyea Software
92295612365
Hot building, ring street
LA, CA
Interneer Inc.
8005586832 x85
6101 W. Centinela Ave.
Culver City, CA
Cornerstone Concepts Inc
818-247-3909
600 W Broadway
Glendale, CA
Greene Computer Corporation
(818) 956-4961
200 S. Louise Street
Glendale, CA
Corticalx Inc Software Solutions & Technology
818-500-0881
425 E Colorado St
Glendale, CA
Alphatier Systems
818-409-8920
517 Griswold St
Glendale, CA
TimeTECH - Customizable Time and Attendance / Workforce Management Solutions
905-677-7009
7420 Airport Rd 203
Mississauga, CA
Hutchinson & Bloodgood, LLP
(818) 637-5000
101 N. Brand Blvd. #1600
Glendale, CA
Telsoft Solutions
818-545-8680
100 N Brand Blvd
Glendale, CA
Abraxas Technologies Inc
818-502-9100
450 N Brand Blvd
Glendale, CA

provided by: 
Originally published at Internet.com


Java Programming Notes # 462 * Preface * General * Viewing tip * Figures * Listings * Supplementary material * General background information * Constructing images * The framework program named ImgMod05 * RescaleOp examples * ColorConvertOp example * Preview * Discussion and sample code * Run the program * Summary * Complete program listing * Copyright * Resources * About the author -----------------------------------

Preface

General

In an earlier lesson titled "A Framework for Experimenting with Java 2D Image-Processing Filters" (see Resources), I taught you how to write a framework program that makes it easy to use the image-filtering classes of the Java 2D API to process the pixels in an image and to display the processed image.

At the close of that lesson, I told you that future lessons would teach you how to use the following image-filtering classes from the Java 2DAPI: * LookupOp * AffineTransformOp * BandCombineOp * ConvolveOp * RescaleOp * ColorConvertOp

In several of the previous lessons listed in the Resources section, I taught you how to use the LookupOp, AffineTransformOp, BandCombineOp, and ConvolveOp image-filtering classes.

In this final lesson of the series, I will teach you how to use the RescaleOp and ColorConvertOp image-filtering classes.

Viewing tip

I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figures and listings while you are reading about them.

Figures

* Figure 1. Image with all three colors inverted. * Figure 2. Image with only one color inverted. * Figure 3. Use of RescaleOp to adjust contrast and brightness. * Figure 4. Conversion of color space to CS_GRAY. * Figure 5. User input GUI with the ColorConvertOp tab selected. * Figure 6. User input GUI with the RescaleOp tab selected.

Listings

* Listing 1. Beginning of the class definition. * Listing 2. Creation of components used to construct the ColorConvertOp page. * Listing 3. Creation of components used to construct the RescaleOp page. * Listing 4. The primary constructor. * Listing 5. The constructColorConvertPage method. * Listing 6. The processColorConvertPage method. * Listing 7. The constructColorRescalePagee method. * Listing 8. The processColorRescalePage method. * Listing 9. The processImg method. * Listing 10. Complete listing of the ImgMod43 class.

Supplementary material

I recommend that you also study the other lessons in my extensive collection of online Java tutorials. You will find a consolidated index at www.DickBaldwin.com.

General background information

Constructing images

Before getting into the programming details, it may be useful for you to review the concept of how images are constructed, stored, transported, and rendered in Java (and in most modern computers for that matter). I provided a great deal of information on these topics in the earlier lesson titled "Processing Image Pixels using Java, Getting Started" (see Resources). Therefore, I won't repeat that information here. Rather, I will simply refer you back to the earlier lesson.

The framework program named ImgMod05

It will also be useful for you to understand the behavior of the framework program named ImgMod05. Therefore, I strongly recommend that you study the earlier lesson titled "A Framework for Experimenting with Java 2D Image-Processing Filters" (see Resources).

However, if you don't have the time to do that, you should take a look at the earlier lesson titled "Using the Java 2D LookupOp Filter Class to Process Images" (see Resources), in which I summarized the behavior of the framework program named ImgMod05.

RescaleOp examples

The RescaleOp class can be used to multiply the color value for each pixel by a user-specified scale factor, and then to add a user-specified constant to the product. Separate scale factors and additive constants are provided for each of the red, green, and blue colors.

Color values that fall outside the allowable range from 0 to 255 are simply clipped to 0 and 255.

Color inversion

Several previous lessons have discussed inverting the colors in an image. This is another class that makes it easy to invert the colors. In this case, the scale factor for all three bands would be set to -1 and the additive constant would be set to 255. This would produce an inverted output image like that shown in Figure 1.

Figure 1. Image with all three colors inverted.

Just in case you have a need to do so, each color band can be inverted separately producing results like those shown in Figure 2. Figure 2 shows the result of inverting only the blue pixels in an image without modifying the red and green pixels.

Figure 2. Image with only one color inverted.

Adjusting the contrast and brightness

Perhaps more importantly, the RescaleOp class can also be used to adjust the contrast and brightness of an image using the concepts that I explained in the earlier lesson titled "Processing Image Pixels Using Java: Controlling Contrast and Brightness" (see

Author: Richard G. Baldwin

Read article at Internet.com site

Featured Local Company

Moyea Software

92295612365
Hot building, ring street
LA, CA

Related Local Events
Automation Technology Expo West (ATX West)
Dates: 2/9/2010 - 2/11/2010
Location: Anaheim Convention Center
Anaheim, CA
View Details

SOLAR POWER - Exhibition and Conference
Dates: 10/12/2010 - 10/14/2010
Location: Los Angeles Convention & Exhibition Center
Los Angeles, CA
View Details

REAL-TIME & EMBEDDED COMPUTING CONFERENCE - LONG BEACH 2009
Dates: 10/1/2009 - 10/1/2009
Location: Marriott Long Beach
Long Beach, CA
View Details

2009 IEEE Petroleum and Chemical Industry Technical Conference (PCIC 2009)
Dates: 9/14/2009 - 9/16/2009
Location:
Anaheim, CA
View Details

Medical Design & Manufacturing - Trade
Dates: 6/9/2009 - 6/11/2009
Location: CANON COMMUNICATIONS LLC
Los Angeles, CA
View Details