How to replace color of an image?

微笑、不失礼 提交于 2019-11-30 07:23:58

The usual way to do this is to use an RGBImageFilter. See the docs for FilteredImageSource for how to use such a filter.

The problem with the issue that you are asking is that a strict color replacement will modify the shape of the image. What you need to do is get a little information on what the shape is. I.e. Find boundaries and shading along the boundaries. My suggestion to you is:

  1. Use edge detection to separate out blobs
  2. Find a blob that fits your demands: i.e. Has a tolerant likelihood for [color]ish.
  3. Identify blobs and filters applied
  4. Recolor the blob and reshade.

IMO: That is the only way you're going to get the result you're looking for.

Some notes: Finding a blob may require some testing to determine how much tolerance you have for blobs and shapes. [Connected Regions].

Another thing: The shading and relative coloring will require you to have a devience for the color you want.

hasbi

I'm not fully understand the question. But from the example given, i see that the process of changing blue into red was fail. instead of becoming red, it becomes gray. does color gray is what you mean by flat?

If that so, it looks like color channel error. to change blue to red, we have to change (0,255,0) to (255,0,0).

I'm not sure if it is the problem, maybe code snippet could help for evaluation. to make sure what is the real problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!