필터 지우기
필터 지우기

change color intensity of rectangles made using matrix

조회 수: 1 (최근 30일)
Anvinder  Singh
Anvinder Singh 2016년 3월 4일
댓글: KSSV 2016년 3월 4일
Hi, Can anybody help me understand the concept of color intensity in the following : I have 2 rectangles of black color. I want to give an intensity of 100 to one of them and 300 to the other one. BUt i want them to remain in the grayscale (they should not be colored but should remain between white and black). Is there a scale which matlab uses for such thing ? Is 256 taken as black or some other value ? I am quiet confused.

채택된 답변

KSSV
KSSV 2016년 3월 4일
Get the color coding from the link: http://www.rapidtables.com/web/color/RGB_Color.htm
% first rectangle
x1 = [0 1/2 1/2 0 0];
y1 = [0 0 1 1 0] ;
% Second rectangle
x2 = [1/2 1 1 1/2 1/2] ;
y2 = [0 0 1 1 0] ;
% fill colors
fill(x1,y1,[51,51,0]/256)
hold on
fill(x2,y2,[0,51,0]/256)
  댓글 수: 2
Anvinder  Singh
Anvinder Singh 2016년 3월 4일
Thanks Dr. Siva. Does % first rectangle x1 = [0 1/2 1/2 0 0]; y1 = [0 0 1 1 0] ;" refer to the location of the rectangle coordinates ? Also, in fill(x1,y1,[51,51,0]/256) what does 51 refer to ?(red and green intensity, blue intensity is zero ?)
KSSV
KSSV 2016년 3월 4일
Hey Anvinder
Yes (x1,y1) refer to the locations of the rectangle. [51,51,0]/256 stand for respective [R,G,B] values. You may check the link for other color variations.
Ps: If you find it useful, don't forget to accept the answer.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by