2020 09 29 Histogram of differences - syntaxmonkey/Thesis GitHub Wiki

Histogram of differences

Leading up to this point, we have been calculating the CIELab colour difference between the two adjacent regions. We would collect all these values and generate attraction thresholds and repulsion thresholds based on some selected percentile. We had assumed some level of normal distribution for the difference values. This assumption is incorrect. As we see below, the histogram of differences is quite skewed towards the zero.

  1. How do we adjust for this? What should the percentiles be?

Here are the distributions for three test images:

Chair

Simple Triangle

Horse

Using histogram bins

The original implementation had assumed a normal distribution for the differences values between regions. Based on the evidence above, the distribution actually resembles negative exponential.

This doesn't change our approach of utilizing percentiles, however, it does impact which percentiles we select.

Given the large number of regions that are similar, we want all those regions to attract. As an approach, we will utilize the bins of the histogram.

For Attraction, any difference value in the first three bins will attract. The values in all the other bins will repel.

Weighted direction average

Originally we were simply averaging the directions of regions. However, this effectively provided each region equal weighting. A better approach is to utilize a region differentiating property. In our case, we will utilize the intensity of the region. Darker regions have greater weight than lighter regions.

Attract/Repel V2

All of the changes above culminate in Attract/Repel V2.

Here are some comparisons. The First image of the pair uses early attract/repel logic. The second image of the pair uses Attract/Repel V2.

The second image may have regions with red lines. The red lines indicate stable regions that have relatively high coherency.

Horse

Chair

Fire Hydrant

Drawing longest line first

In drawing lines for the region, we simply started at the first index in the list. However, the first line was not always the longest line in the region. For areas with that have very few, even just one line, this could result in sparse small lines. In these sparse regions, we want to display the longest line possible. We will still allow shorter lines, however, given that the regions are sparse, there will likely be only one line. We have made this change and it has a large impact on the sparse regions as can be seen below.

The first image contains small lines in the sparse areas. The second image contains long lines in the sparse regions.

Region Angle visualization

Now generating new visualization that better identifies the angle of each region. We simply draw the longest line of the region. Both images are of the same image. The first image does not contain the SLIC region outlines while the second image does contain the SLIC region outlines. The SLIC region outlines make it much easier to assess the appropriateness of the region angles.

Refining the Attract/Repel algorithm

In the current algorithm (Attract/Repel 2), regions of lower intensity cannot update the angle of a region with higher intensity. This introduces regions that act as blockages. In the image below, we see there are two dark regions up the handle of the blade. On either side of the the darker regions are lighter regions. Since the lighter regions cannot update darker regions, the darker regions effectively become immutable. Attract/Repel 3 will change this behaviour. Lighter regions will now be able to update darker regions. However, since we utilize the intensity as the weighting, the darker regions still have a larger pull.

Results

Making that change in Attract/Repel does solve part of the problem to a certain degree.

Allow blank regions

We try allow blank regions. If the intensity of a region is above a certain threshold, we automatically draw no lines in that region.

Results

The upper portion of the image is blanked. However, the blank region is only a portion of the sky. The blank portion of the etched image almost implies a feature boundary that does not exist in the original image.

However, when the lighter region is removed sufficiently completely, the effect is acceptable.

Vary line width

We implement line width variation based on region intensity.

Results

The resulting etching has thinner lines in regions that are lighter. In combination with blank regions, the effects are more acceptable. When blank regions were implemented full intensity lines, there was an abrupt stop to the lines. With varying line thickness, the transition is more gradual.

Vary line width without blank regions

We want to compare allowing blank regions vs not allowing blank regions.

Results

Two things are visible. First, images such as the horse where the background is lighter, but is not completely white, does have the desired effect. The lighter regions are not as thick and as a result are not as visually dark. Most of the images exhibit this behaviour to varying degrees. The result is that the darker images are more visible.

The hands are an inverted image where the background is darker than the object of interest. Here the contrast as is not strong. Although the outlines of the hands are visible, the separation of the object from the background is not as pronounced.

Second, in the synthetic image of the triangle, the background has an intensity of 255. These regions should have the thinnest lines. However, the lines are not visible. The drawing package has a practical limit for line thickness. This have a similar effect as allowing blank regions. However, as noted before, this approach is less abrupt than the allowing blank regions. This approach has the possibility of gradually fading regions until they become blank.

Vary line thickness without reducing line density

Lighter regions currently experience a double reduction in coverage: reduced line density and reduced line thickness. To produce a proper comparison, we will make the line density static.

Results

The line with variation with constant line density works somewhat. Perhaps the most dense regions should have more lines. If we look at the synthetic triangle, the body of the triangle should be 0 intensity. It should have a higher level of coverage.

Tweak line coverage

Regions with an intensity of zero should have near 100% line coverage. Need to experiment to determine what value that should be.

Also should make intensity 255 have the smallest line possible. Try using this function to determine line width: (-regionIntensity/255) + 1.01.

Results

There varying levels of success with this approach. The line thickness definitely has the effect of indicating darker regions. However, in the case of the chair, it is not a very large visible difference despite the visual different in colour intensity. Based on the synthetic triangle image, this scheme works almost perfectly. The background regions are almost white because of how thin the lines are. Similarly, the pineapple is well presented with the light background.