필터 지우기
필터 지우기

Creating a color image

조회 수: 18 (최근 30일)
PenguinForce
PenguinForce 2016년 10월 1일
댓글: PenguinForce 2016년 10월 2일
I am trying to create a 256X256 image that starts out blue on the left hand side and scales down by one index every column so that it is black on the right side, kinda like in this picture but opposite direction but I cannot get this code to preform. How can I achieve this? Is there also a way to do this vertically as well, ie, blue on top scaling down to black on the bottom?
image(:,:,1)= zeros(256,256,1);
image(:,:,2)= zeros(256,256);
for i=1:256
image(i,:,3)= [255:-1:0];
end
image=image/255;
imagesc(image)

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 2일
Blue_image = zeros(256, 256, 3, 'uint8');
Blue_image(:, :, 3) = repmat(255:-1:0, 256, 1);
Please avoid using image as a variable name, as it is the name of an important MATLAB routine to display images.
  댓글 수: 1
PenguinForce
PenguinForce 2016년 10월 2일
Thank you! I did not know that about the image variable name but thank you for letting me know! I appreciate your time

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by