Borrar filtros
Borrar filtros

How do I change the color channel's value using variables?

3 visualizaciones (últimos 30 días)
Maria Jeseca Baculo
Maria Jeseca Baculo el 15 de Ag. de 2017
Comentada: Maria Jeseca Baculo el 16 de Ag. de 2017
I am working on a project which aims to recolor a certain part of an image. I created a matlab function that accepts numerical values for the RGB channels. However, this code will only run once smoothly, then on the succeeding executions, a mismatch error will appear. What seems to be the problem with my code? Thanks :)
% Extract the individual red, green, and blue color channels.
redChannel = maskedImage(:, :, 1);
greenChannel = maskedImage(:, :, 2);
blueChannel = maskedImage(:, :, 3);
% Make the red channel that color
redChannel(edge2) = red;
greenChannel(edge2) = grn;
blueChannel(edge2) = blu;
maskedImage = cat(3, redChannel, greenChannel, blueChannel);
  5 comentarios
Maria Jeseca Baculo
Maria Jeseca Baculo el 15 de Ag. de 2017
also, the parameters are sent by a python web app via matlab engine. Thanks again :)
Maria Jeseca Baculo
Maria Jeseca Baculo el 15 de Ag. de 2017
yes, I made sure that the values are uint8 values, the thing is, the code works fine with constant values. But when these variables are used, it only runs once without the error.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 15 de Ag. de 2017
Either edge2 is not the same size as redChannel, or red is not a single number but an array.
  1 comentario
Maria Jeseca Baculo
Maria Jeseca Baculo el 16 de Ag. de 2017
I tried converting the arguments to int in python prior passing them in matlab and now it works! Thank you :)

Iniciar sesión para comentar.

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by