How to do gouraud shading? [closed] - graphics

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Could someone explain Gouraud shading to me? I can go ahead and Google "gouraud shading", but it doesn't make much sense to me. I have 3 vertices with an (x, y) position and an int[r,g,b] color. I want to linearly interpolate (not sure what this means) the colors of the vertices to shade in the triangle. What is the logic for doing so?

You will perform a bi-linear interpolation.
Scan the triangle from top to bottom, following the rows of pixels. Every row will intersect the triangle twice, along two distinct edges.
You will first perform two linear interpolations along these edges, computing a mixture of the RGB components at the vertices, weighted with the distances to these (weight Db/(Da+Db) for color a and Da/(Da+Db) for color b).
Then you will scan the pixels between the intersections, performing another linear interpolation between the two colors you just computed.
This way you will fill the triangle with a smooth gradient, in a way that will make it continuous with neighboring triangles, if any.

Related

Straight lined scatter over marked scatter plot [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm trying to make a simple scatter plot in Excel. One variable are field measures of river flow. The other one is the fitted rating curve (done externally). I draw the field measures as marked scatter plot. For the rating curve I created a column with the water level at each centimeter and the respective water flow calculated with the curve equation. With this pair (water level, water flow) I have added a second series and changed from marked scatter to straight lined scatter plot.
The problem is that I need to see the rating curve over the measures plot. I had changed the plot order but didn't work. The marked plot is always over the lined one.
Any suggestion!?
I have not had success with changing series order causing scatter data to appear behind a line. Even though the order of the Legend will change, the plot order does not appear to be affected.
In order to get your line to appear in front of the scatter data, you will need to put the line on the Secondary Axis, then make sure your min/max values for the secondary axis are the same as the primary.
If you don't want to see the secondary axis set the Label Position to None.

Graphing in Excel [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have these values
Temperature
4
25
37
55
80
and
Rate
.1235
.092
.0864
.057
.0044
I wish to create a bar graph with Rate on the X-axis and Temp on the Y-axis.
I create a spreadsheet with the values and highlight the data.
Then I click on insert clustered column graph.
However, it gives me temp on the y axis and the numbers 1 through 5 on the x axis.
How can I make it so Rate is on the X-axis and Temp is on the Y-axis?
Isn't rate going to be dependent on temperature? If so, temperature should be the independent variable (X) and rate the dependent variable (Y).
Aren't these continuous measurable quantities? If so, rather than a bar chart, you should probably make an XY Scatter chart. (As Pnuts hinted at.)
Put your X values into a column, and your Y values into the next column, as shown below, then insert an XY Scatter chart. I used the style with markers and straight lines.

how to calculate pixel density of a sampled binary image [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
This may be a very simple matter, but I have conflict with that. I have split a particular binary image (28 x 28) into (4 x 4) samples. Now I want to calculate the pixel densities of each sample (I use those density values as features in a OCR application). As I know density defines the number of pixels in a particular area, like 7 pixels per square inch. Is that the same in here? all of my samples have 4 pixels. Is there are relationship between Moment->m00 and pixel density? Can someone explain this? plz help
A "density" depicts how much of "a thing" corresponds to a "small fraction of space".
In terms of images, that might be i.e. "amount of colour" that a "fragment of image" holds.
For black and white or grayscale images that are held as pixel arrays that could simply mean an average pixel value.
For example, if your image is black and white (that is, pixels have value either 0 or 1): If your sample is a 4x4 square, then its area is 16. In this area you can have from 0 to 16 pixels, what would be respectively 0.0 and 1.0. Here a 4 black pixels and 12 white could indicate a density of 4/16 = 0.25 (or 12/16 = 0.75, depending on which pixels you treat as "empty" (black or white?)).
For example, if your image is grayscale (that is, pixels have values in range of 0..255 which describes how white they are): If your sample is a 4x4 square, then its area is 16. In this area you can have from 0 to 16 pixels, what would be respectively 0% and 100%. All but four pixels "empty", and those four have values 100,100,50,50 gives you density of (100+100+50+50)/255/16 = 0.073 . Mind that pixels have min=0 and max=255 values. If your pixels have different value ranges, adjust appropriately.
In terms of OpenCV, I'd assume that moment->m00 is a "spacial image m=0,n=0 moment". So, you might want to review i.e. http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch11/ch11_image_moments.html
Looking at that document and the formulas, I think that you will find your density either in m00 or in m11 fields. I think that since m and n are 0, then m00 will be equal to 1(one), and the m11 will hold the average pixel value of the 2D image, but I've not tried/checked so I am not 100% sure.

Distance between triangle and a point in 2D [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to calculate the shortest distance between a point and a triangle.
I tried the following,
1. Calculate the centroid of triangle.
2. Form a line between the centroid and the point.
3. Find which side of triangle is intersection with the above formed line.
4. Find the perpendicular distance between the point and the intersecting line found in step (3).
Am I doing something wrong? Can anyone help me in getting the distance?

Find nearest color [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Similarity Between Colors
I know it's not a programming question but I think the understanding of the color models is always bound to a programmer's life.
So we were having an argument about a certain color in the office. I was saying that a particular color was more near to pink and a colleague said it was more close to purple.
The question is how can I measure the distance of a color from another color?
Example:
Pink=(255, 192, 203) -->A
Purple=(128, 0, 128) -->B
Color in question=(232,143,253)-->C
The A or B is closest to C?
A simple method is to calculate the Euclidean distance in the RGB cube using the formula:
√((r2-r1)2 + (g2-g1)2 + (b2-b1)2)
However this won't accurately measure the human perception of closeness. For example, the human eye is more sensitive to some colours than others. To take this into account you will need to look at some research on the topic of human perception of colour. This Wikipedia page has some good starting points: Color difference

Resources