필터 지우기
필터 지우기

assign background color to average of points

조회 수: 2 (최근 30일)
Anastasia
Anastasia 2017년 2월 7일
편집: Image Analyst 2017년 3월 7일
Hey guys! I am new to matlab and I am trying to figure this problem out... I have a program that calculates some operations and then gives me a series of numbers of 1, 2 or 4 (the variable’s name with the numbers 1, 2 or 4 is S) which then I plot (Image2 in attached files).
I would like each point to be the average of the three points (the one before and the one after and the point himself) and assign a color to the background for each number. For ex, when the average is 1, I would like a red color in the background, dark blue for 2 and yellow for 4 (if other colors are better, I am open to it). When the average is not 1, 2 or 4 but:
- 1+1+2 (or 1+2+1, or 2+1+1)=4/3=1.333
- 1+2+2=5/3=1.667
- 1+1+4=6/3=2
- 1+4+4=9/3=3
- 2+2+4=8/3=2.667
- 2+4+4=10/3=3.333
I would like an intermediary color.
For the numbers between 1 and 2 I would like to assign colors between red and dark blue: - Pink for 1,333 and purple for 1,667
For the numbers between 1 and 4 I would like to assign colors between red and yellow: - Pale orange for 2 and dark orange for 3
For the numbers between 2 and 4 I would like to assign colors between blue and yellow: - Green for 2.667 and pale blue for 3.333
The aim is to have a kind of continuity (visually) between the numbers from 1 to 4, and would look something like the Image3 (only the beginning).
Thanks in advance for any help!!

답변 (1개)

Image Analyst
Image Analyst 2017년 2월 7일
편집: Image Analyst 2017년 2월 7일
Try conv() or movmean()
aveSignal = conv(signal, ones(1,3)/3, 'same');
Then use patch() or fill() to fill the rectangles with color.
  댓글 수: 8
Anastasia
Anastasia 2017년 3월 7일
Hello, only RGB image would be perfect, without the graph! Thank you for your response!
Image Analyst
Image Analyst 2017년 3월 7일
편집: Image Analyst 2017년 3월 7일
Unfortunately you forgot to attach your data. I'll check back later for it. And how many distinct colors do you want? Is your data integers only, or fractional numbers? Do you want one color for each integer? Or thousands of colors for thousands or millions of possible floating point numbers?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by