Changing hair color in a photo using matlab
    조회 수: 5 (최근 30일)
  
       이전 댓글 표시
    
rgbColorImage = imread('peppers.png');
% Extract the individual red, green, and blue color channels.
          redChannel = rgbColorImage{ii}(:, :, 1);
          greenChannel = rgbColorImage{ii}(:, :, 2);
          blueChannel = rgbColorImage{ii}(:, :, 3);
          % Specify the color we want to make this area.
          desiredColor = [146, 40, 146]; % Purple
          % Make the red channel that color
          redChannel(maskedImage) = desiredColor(1);
          greenChannel(maskedImage) = desiredColor(2);
          blueChannel(maskedImage) = desiredColor(3);
          % Recombine separate color channels into a single, true color RGB image.
          rgbColorImage{ii} = cat(3, redChannel, greenChannel, blueChannel);
Undefined function or variable 'ii'.
Error in color_change_red_into_blue (line 92)
          redChannel = rgbColorImage{ii}(:, :, 1); 
I get this error. What do you recommend ?
답변 (1개)
  Image Analyst
      
      
 2021년 9월 11일
        rgbImage is not a cell array so you don't use braces.  Get rid of the {ii}.  It should be done like
% Extract the individual red, green, and blue color channels.
[redChannel , greenChannel,  blueChannel] = imsplit(rgbColorImage);
maskedImage has not been defined at all, so that will cause an error when your program gets to that.  You need to define maskedImage as a binary image in order to use it as a logical image like you're trying.
댓글 수: 4
  Image Analyst
      
      
 2021년 9월 11일
				OK, good.  Glad you got it working.  To display (not print) the image to the screen you can use imshow():
imshow(rgbImage);
assuming the variable you saved to the workspace is called rgbImage.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


