# How to generate surface of fixed width from know coordintes of curve and add pixel covered by the surface

조회 수: 1(최근 30일)
Prabin 10 Apr 2015
댓글: Image Analyst 12 Apr 2015
I have a set of points that describe a curve but i need to take a surface of fixed width above or below the curve and add all the pixel value covered by the surface.Any help will be appreciated.The question is made clear in the figure attached.

로그인 to comment.

### 답변(2개)

Ben11 10 Apr 2015
This should do it:
clear
clc
close all
%// Define x and y to plot curve
x=-10:10;
y=-x.^2;
%// Build 2 other arrays for y values of shaded region
y1 = y-4;
y2 = y+4;
%// Set up x and y values to fill the region
X=[x,fliplr(x)];
Y=[y1,fliplr(y2)];
%// Fill area
hFill = fill(X,Y,[.5 0 1]);
set(hFill,'FaceAlpha',.5)
hold on
plot(x,y,':b','LineWidth',2)
Output:
I'll let you discover how to remove borders of the shaded region

#### 댓글 수: 1

Prabin 10 Apr 2015
Thank you for your answer. but the main problem is finding the pixel value of the surface.i can find the pixel value of the known coordinates by using impixel but any idea how can i do that for whole shaded region too

로그인 to comment.

Image Analyst 10 Apr 2015
yTop = y + someAmount;
yBottom = y - someAmount;

#### 댓글 수: 2

Prabin 12 Apr 2015
thanks for your answer but i am working on symmetrical wave propagation of waves so this method is not much effective.If you can help me with finding the pixel value of surface as created above would be a great help or if you can share any information on making all the pixel zero except of the surface created .
Image Analyst 12 Apr 2015
Sorry, I guess I can't because I don't see how adding and subtracting some amount from the centerline won't give you the coordinates of the upper and lower envelopes.
And it looks like a 1-dimensional problem so I'm not exactly sure why you're referring to a "surface" which I usually think of as a 2 or 3 D concept.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

Translated by