HCW-Modify Program Version 1.2.2.0

/Home /Professional /Papers /ColorHCW /HCW-Modify

Contents

Introduction

The HCW-Modify program modifies graphics files using the HCW color representation described in the ColorHCW.html document. The program was developed for simple graphics files specifically to correct problems with JPEG artifacts. Additional functions were added as needed. The original program was a simple console application which only had the limitation of not being able to see the graphics as they were being modified. The Windows Forms version of the program allows easy visualization of changes and comparison with the original graphic.

The program was originally designed and used for clip art composed of solid colors and gradients. The pictures had black edging around individual components similar to stained glass. Other types of graphics will not work as well.

Release Notes

Version 1.2.1.0 release 2011-10-21:

Bug fix/feature improvement for HCW Transform Dialog now includes a selection to limit transforms to Hue/Chroma or Hue/White. The interactions of Chroma and White values are to complex to allow both to occur at the same time.

Version 1.2.1.0 release 2011-10-21:

Bug fix/feature improvement for HCW Transform Dialog adding Chroma/White compensation. Documentation improvements describing HCW Transform Dialog details of Hue wrap-around and Chroma/White compensation.

Version 1.2.0.0 release 2011-07-25:

Added new features:

Fill Gradient

Version 1.1.0.0 release:

Added new features:

Analyze HCW Distribution

Grayscale

Black/White

Bug fix for HCW Transform with a circular Hue range wraparound. HCW Transform dialog is also now modal.

Menu bar

The menu bar contains the menu groupings for all the functions performed by the HCW-Modify program.

File Menu

The file menu contains the typical functions for handling file operations and exiting the program.

Open

An open file dialog is shown to select the graphics file for processing. If a file is already open and the image has been modifed, you will be offered the option to save the image to a file. If the save is cancelled, the modifed image will be lost.

Two windows are displayed which are labelled "Original Image" and "Unmodified Working Image". The original image is always displayed to allow comparison with the results of any editing changes. The working image is initially a copy of the original and shows the results of any editing changes. The window title changes to indicate the last editing operation performed.

Revert to Original

This option is not enabled unless there is a file open. The working image will be reverted to a copy of the original image. If the image has been modifed, you will be offered the option to save the image to a file. If the save is cancelled, the image will still be changed.

Close

This option is not enabled unless there is a file open. If the image has been modifed, you will be offered the option to save the image to a file.

Save As

This option is not enabled unless there is a file open. A dialog is displayed suggesting a file name for the image. The file name defaults to the input file name with "-2" appended in the same directory. You are not allowed to save over the original file. You may change the name and directory as desired.

Exit

This option will exit the program. If the image has been modifed, you will be offered the option to save the image to a file. If the save is cancelled, the program will still exit and the modified image will be lost.

Edit Menu

The various function to modify the image are grouped under the edit menu. This menu will not be enabled unless there is an image to be modified.

Blacken

This option will set all nearly black pixels to absolute black. This is helpful when you wish a completely black background to allow transparent pasting. You are prompted for the cutoff level to consider black. The color White (255, 255, 255) will also be changed to (254, 254, 254) so that a paint operation (in Paint) of white over black will not accidently interact with white in the picture.

Edge

This option is primarily useful after the Blacken command to maintain an edge which is not pure black around every part of the graphic. This assists with transparent pasting. You are prompted for the width of the edge in pixels. Each outline is one (invisible) level of white higher to distinguish it from Black. For example, a single edge would have an RGB color value of (1, 1, 1).

Toggle B/W

This option makes it easy to see changes from the Blacken and Edge commands. All occurences of Black are changed to White at the same time all occurences of White are changed to Black. The option is used twice to return the image to its normal background.

Compress

This option removes intermediate values which may not contribute to the image and result in a more compressible file. You are prompted for the number of intermediate values to remove. A value of 1 truncates all odd values to even values (%2 or mod 2), a value of 2 is (%3 or mod 3), and so on. A compression value of 3 or mod 4 is nearly indistinguishable. Higher values will produce banding effects in color gradients.

Gradient Smooth

A gradient smoothing pass compares three consecutive non-edge pixels in horizontal, vertical, and crosswise directions. If the two slopes from the center pixel diverge more than two units in Red, Green, or Blue values from the same tilt, two units are removed from the center pixel with one each added to the outside pixels. This change is kept small to avoid disruptive shifts but can be repeated many times. You are prompted for the number of smoothing passes to repeat.

HCW Transform Dialog

Clicking this option will popup a modal dialog box which will allow you to specify the HCW selection values to select pixels in the source range and to specify the target range to transform each selected pixel to a target value. The HCW Transform Dialog has a selection to limit transforms to Hue/Chroma or Hue/White. The interactions of Chroma/White are to complex to allow both to occur at the same time.

The simplest example to ilustrate this function is a Hue only change. The target values for Chroma/White are set identical to the selection values. For example, to change all pure yellow values to pure blue. The hue selection range would be 600-600 and the target range would be 2400-2400.

Since most images have a range of yellows you may wish to change everything near yellow to near blue. An example is a hue selection range of 580-620 and a target range would be 2380-2420.

You may wish to change everything near yellow to pure blue. An example is a hue selection range of 580-620 and a target range would be 2400-2400.

You could also change everything near yellow to pure yellow. An example is a hue selection range of 580-620 and a target range would be 600-600.

The value for hue is actually a continuous range from 0 - 3599 which is immediately followed by 0. If you wanted to indicate a range of red values then the starting number is actually larger than the ending value of the range. Near red is therefore approximately 3580-20. This is called a wrap-around range whenever the lower value is higher than the upper value. A selection range excluding everything except near red would be 20-3580. A selection range including everything except near yellow would be 620-580.

Unlike Hue, the values for Chroma and White do not wrap around. It means exactly the same thing whether the lower value is higher than the upper value or not.

When a Hue/Chroma selection is chosen the White target is set to 0 and is ignored. When a Hue/White selection is chosen the Chroma target is set to 255 and is ignored. This is necessary because the desired target range for the White values must be less than or equal to the Chroma values.

There are a large number of possibilities available with this function.

Perform Transform

Clicking this button will perform the HCW transform according to the specified selection and target ranges.

The Chroma and White values have an interaction which is not obvious. Changing one of the Chroma or White values has an effect on the other value. The range of the White value is limited by the Chroma value. Therefore, changing one without changing the other causes some visual distortions of color. The program automatically compensates and scales for this distortion. The scaling is done according to the actual Chroma and White values of each pixel not according to the Transform values.

For example, If you wanted to make an image lighter you would want to transform the White values to a higher range. I find this useful when compensating for printing a video image. Bright colors appear darker when printed. I use a selection range for White of 0-255 with a target range of 64-255. Values between 0 and 255 are scaled to be between 64 and 255. This does cause a problem with black or near black. Therefore, I use a selection range which excludes blacks.

The problem is that colors tend to get washed out and shift toward a gray scale, if you do not adjust the chroma upward to compensate for an increase in the white value. A similar problem occurs with a decrease of the white, increase in the chroma, or a decrease in the chroma.

Example scaling of individual pixel values:

Change  »    «  
Chroma2128
White00
White164
White2128
 
Change  »    «  
Chroma126254
White00
White63127
White126254
 
Change  »    «  
White1129
Chroma1129
Chroma64160
Chroma128192
 
Change  »    «  
White253127
Chroma253127
Chroma254191
Chroma255255

Transform Option Settings

The five HCW options provide the ability to view and set HCW selection values. The Current Color option is only used for reference. The rest are used for the HCW Transform editing function. Click on any selection to change its value with the Color Picker.

Each button displays its current setting with three color blobs.

  • The first color blob shows the actual Hue value with a Chroma value of 255 and a White value of 0.
  • The second color blob shows the actual Hue value with the actual Chroma value and a White value of 0.
  • The third color blob shows the actual Hue value with the actual Chroma value and the actual White value.

Current H: ??? C: ??? W: ???

This is the Current selection HCW values. These are usually picked from the graphic as a reference value. The Current color is only used for reference.

Selection Lower H: ??? C: ??? W: ???

This is the lower boundary of the selection region for selecting the source HCW value range.

Selection Upper H: ??? C: ??? W: ???

This is the upper boundary of the selection region for selecting the source HCW value range.

Target Lower H: ??? C: ??? W: ???

This is the lower boundary of the target region for changing the target HCW value range.

Target Upper H: ??? C: ??? W: ???

This is the upper boundary of the target region for changing the target HCW value range.

Set to Current Options

The four option buttons provide the ability to set the HCW options to the Current HCW value.

Set to Default Options

The four option buttons provide the ability to set the HCW options to a Default value. The default values will selecte verything except Black and White and make no change in values for the perform transform.

The lower default value is:

H: 0 C: 1 W: 0

The upper default value is:

H: 3599 C: 255 W: 254

Example transform options

These example options will select every pixel which is near green and change it to blue without changing the Chroma or White value:
  • Selection Lower H: 1100 C: 1 W: 1
  • Selection Upper H: 1300 C: 255 W: 254
  • Target Lower H: 2400 C: 1 W: 1
  • Target Upper H: 2400 C: 255 W: 254
These example options will select every pixel which is near green and scale the Chroma value higher without changing the Hue or White value:
  • Selection Lower H: 1100 C: 1 W: 1
  • Selection Upper H: 1300 C: 255 W: 254
  • Target Lower H: 1100 C: 128 W: 1
  • Target Upper H: 1300 C: 255 W: 254
These example options will select every pixel which is a bright background color and scale the Chroma value and the White value to 255 to make it white. This is the first step of a method to change a color picture to B/W:
  • Selection Lower H: 0 C: 129 W: 129
  • Selection Upper H: 3599 C: 255 W: 255
  • Target Lower H: 0 C: 255 W: 255
  • Target Upper H: 3599 C: 255 W: 255
These example options will select every pixel which is not bright and scale the Chroma value and the White value to 0 to make it black. This is the second step of a method to change a color picture to B/W:
  • Selection Lower H: 0 C: 1 W: 1
  • Selection Upper H: 3599 C: 128 W: 128
  • Target Lower H: 0 C: 0 W: 0
  • Target Upper H: 3599 C: 0 W: 0

Grayscale

There are three Grayscale conversion functions.

Overlapping

This function adds together 30% of the red value, 59% of the green value, and 11% of the blue value and sets all values to the result for each pixel in the image. This produces a nice smooth grayscale conversion.

Reversible

This function severely restricts colors to bits which is a crude grayscale but has the unique function of being partially reversible. This creates an interesting visual effect.

Undo

This function performs the reverse of the reversible grayscale and partly restores the original color with a certain degree of accuracy. This also creates an interesting visual effect.

Black/White

The Black/White conversion requests a white level at which to select whether the color is converted to white or black for each pixel in the image.

Fill Gradient

This function prompts on the status line for you to click on an area to select a center location for the fill. You are prompted for the color to fill from the left-center with a gradient color. The complete contiguous area of the same color is filled with the current color as a gradient. You are then prompted for the final White value for the fill to the right edge. You are then prompted for the final Chroma value for the fill to the top and bottom edge.

The area is assumed to be a basically simple geometric shape from square to oval or circular. The fill will not track well around edges.

View Menu

The View Menu provides any options available to change the way the program displays on the screen.

Status Bar

The optional display of the status bar is selected.

Display Pixels Changed

This option controls the display of the "Pixels Changed" popup box. When checked, the box will display the number of pixels changed after any editing operation.

Tools Menu

Various tools are available under this menu.

Color Picker

The color picker is a display of the currently selected color and its associated HCW and RGB values. These can be modified to select different colors. The color picker is automatically displayed when you click on either the original or the modified image. The color under the tip of the mouse pointer becomes the selected color.

The color picker is also shown to select the input value to certain editing functions.

The color picker is a valuable tool to become familiar with the results of changing and converting HCW and RGB values.

HCW Palette

If the current image has been modifed, you will be offered the option to save the image to a file before the tool performs its function. If the save is cancelled, the modified image will be lost.

The function of the tool is to create a window and display an image which is a rectangular projection of the HCW hexcone. This shows the color wheel as a full range of primary hues in the horizontal dimension with increasing White values going up in the vertical dimension and decreasing values of Chroma going down. The image is also reflected in the vertical dimension. Refer to the ColorHCW.html section on Visual Representations for a description of this type of representation.

When the window is closed, you will be offered the option to save the image to a file.

HW Palette

If the current image has been modifed, you will be offered the option to save the image to a file before the tool performs its function. If the save is cancelled, the modified image will be lost.

The function of the tool is to create a window and display an image which is a hexagonal projection of the HCW hexcone. This shows the color wheel as a full range of primary hues in the outside dimension with increasing White values going toward the center. Refer to the ColorHCW.html section on Visual Representations for a description of this type of representation.

When the window is closed, you will be offered the option to save the image to a file.

HC Palette

If the current image has been modifed, you will be offered the option to save the image to a file before the tool performs its function. If the save is cancelled, the modified image will be lost.

The function of the tool is to create a window and display an image which is a hexagonal projection of the HCW hexcone. This shows the color wheel as a full range of primary hues in the outside dimension with decreasing Chroma values going toward the center. Refer to the ColorHCW.html section on Visual Representations for a description of this type of representation.

Custom Palette

If the current image has been modifed, you will be offered the option to save the image to a file before the tool performs its function. If the save is cancelled, the modified image will be lost.

The function of the tool is to create a window and display a custom palette image which is a flat/wide hexagonal projection of the HCW hexcone. This shows the color wheel as a full range of primary hues in the outside dimension with increasing White values going toward the center. Refer to the ColorHCW.html section on Visual Representations for a description of this type of representation.

When the window is closed, you will be offered the option to save the image to a file.

Hue Gradient

If the current image has been modifed, you will be offered the option to save the image to a file before the tool performs its function. If the save is cancelled, the modified image will be lost.

The function of the tool is to create a window and display a gradient bitmap of the current color. This bitmap can be used with matte masks.

When the window is closed, you will be offered the option to save the image to a file.

Memory Used

This option will perform a garbage collection and display the amount of dynamically managed memory used. This is not the same as the total amount of memory used by the program. In fact it is far less. Primarily it is the amount of memory used to hold the open image and its bitmaps.

Analyze HCW Distribution

This option will display three graphs of the distribution for the Hue, Chroma, and White levels in the modified image. Near Black (Chroma: 0 - 7) and near white (White: 249-255) values are removed in the Hue graph. Chroma: 0 - 1 and White: 254-255 values are clipped in the other graphs. All vertical distributions are scaled from 0 to 255. Horizonal grid lines indicate intervals of 16.

Vertical grid lines indicate intervals of 8. Hue values are grouped by degree.

Windows Menu

This menu contains options to control the placement and dsiplay of the MDI child windows.

Cascade

Display all open windows in a cascade.

Tile Vertical

Display all open windows tiled vertically

Tile Horizontal

Display all open windows tiled horizontally

Close All

Close all open windows.

If the current image has been modifed, you will be offered the option to save the image to a file before the window is closed. If the save is cancelled, the modified image will be lost.

Help Menu

This menu contains options for help and program information.

Online Contents

This option will open the web site "http://www.frank-t-clark.com/Professional/Papers/ColorHCW/HCW-Modify.html" which contains the online version of the documentation for the current version of the program.

This web page may be saved to the "HCW-Modify.html" file in the directory with the program. This updates the Local Contents. Links from the page will fail unless more pages and images are copied to the directory.

Local Contents

This option will open the local web file "HCW-Modify.html" which contains the local version of the documentation for the program. The file is expected to be in the same directory as the program file. Links from the page will fail unless more pages and images are copied to the directory.

About

This option displays the program version number and other information.


Revised 2011-11-13