【问题标题】:how to change the color of one portion of an image to another portion of the same image using MATLAB如何使用MATLAB将图像的一个部分的颜色更改为同一图像的另一部分
【发布时间】:2013-05-04 07:20:49
【问题描述】:

我有一张彩色图片。图像由具有阴影的对象组成。我已经去除了阴影,但阴影部分的颜色与背景颜色不相似。现在如何使用 MATLAB 编码匹配颜色?

【问题讨论】:

  • 您可以访问阴影像素吗?

标签: image matlab image-processing colors rgb


【解决方案1】:

您可以更改与您的图像相对应的 matlab 矩阵(此处称为 IMG)。例如,假设您将阴影的像素更改为 -20。 比你可以让他们的索引做

indexes = (IMG == -20)

要将这些值更改为背景颜色,假设等于 100,例如,您设置比做

IMG(indexes) = 100

由于您使用的是彩色图像,因此您需要对与您的图像对应的所有三种颜色矩阵执行此操作。在这种情况下,您将为每个图层设置一个背景颜色,而不是重复该过程

indexes1 = (IMG(:, :, 1) == shadow_color_layer_1)

indexes2 = (IMG(:, :, 2) == shadow_color_layer_2)

indexes3 = (IMG(:, :, 3) == shadow_color_layer_3)

IMG(indexes,1) = background_color_layer_1

IMG(indexes,2) = background_color_layer_2

IMG(indexes,3) = background_color_layer_3

【讨论】:

  • 但是我怎样才能得到 shadow_color_layers 和 Background_color_layers?
  • 查看矩阵,打开它并使用 imshow() 或其他更合适的方法将其可视化。您应该逐层可视化。你想让你的方法自动找到背景并替换阴影吗?如果这是你的情况,那就更难做到了。
猜你喜欢
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多