8. Filling Colors by Sections
- Walter Cheng
- Jul 16, 2019
- 2 min read


Now we've got different version of the image that has been colored, but it is not enough for a science-fiction style image. Most of them have two theme color in different section, therefore, in this chapter, we would like to investigate how to achieve this.
First, we need the original image.

By using distance transform and watershed algorithm, we would be able to generate something like that to cut the section of the image



Well, this picture filled every single sections the algorithm had decided as white, which is not clear which is which since it is really just filling most of the area in. Therefore, we can fill in different colors to separate it.

Now there is a problem, there are ways too many section to fill in and as we mentioned, most of them only contains one to two colors. Therefore, we would like to select only part of the sections to fill in one, and the rest to fill in others.


For this image, it is fairly straight forward since we just have to make the upper part and the lower part. According to the output of the algorithm, the section is ordered from top and bottom so it is easy to just separate it. However, if some images are separated by left and right or other special rule, then we might have to manually select those sections.
If we just fill in color according to the sections above without manipulating anything else, the result will be here,

which is, well, a little bit awkward. Therefore, we would like to use something to make the color change more smoothly
By normalizing the section color above, we would get this


when we applied white to 1 and black to 0, we would get the ratio for the image and start to have some gradient looking color.

There are some number to adjust the value of how to normalize the image, and those numbers will directly affect the area and the brightness of the "ratio image" that we generated, which can be seen in another result:

Also, here is other examples for these images:




Side note for this chapter, not every single pictures can be a successful science fiction style, some might generate some bad result, it really relies on the source image whether it can be a good science-fiction style.


credit:



Comments