 Tags IOS SQL HTML C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 # Calculate the white pixel inside cv2.circle

By : vaschops
Date : July 31 2020, 04:00 PM
around this issue I am not sure what you consider as "white", but here is one way to do the counting in Python/OpenCV. Simply read the image. Convert to grayscale. Threshold it at some level. Then just count the number of white pixels in the thresholded image.
If I use your output image for my input (after removing your white border): code :
``````import cv2
import numpy as np

# convert to HSV and extract saturation channel
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)

# threshold
thresh = cv2.threshold(gray, 175, 255, cv2.THRESH_BINARY)

# count number of white pixels
count = np.sum(np.where(thresh == 255))
print("count =",count)

# write result to disk
cv2.imwrite("optic_thresh.png", thresh)

# display it
cv2.imshow("IMAGE", img)
cv2.imshow("THRESH", thresh)
cv2.waitKey(0)
``````
``````count = 1025729
``````

## How do I calculate pixel shader depth to render a circle drawn on a point sprite as a sphere that will intersect with ot

By : Suraj
Date : March 29 2020, 07:55 AM
will be helpful for those in need I came up with a solution yesterday, which which works well and and produces the desired result of a sphere drawn on the sprite, with a correct depth value which intersects with other objects and spheres in the scene. It may be less efficient than it needs to be (it calculates and projects two vertices per sprite, for example) and is probably not fully correct mathematically (it takes shortcuts), but it produces visually good results.
The technique
code :
``````void SphereVS(float4 vPos // Input vertex,
out float fDXScale, // Result of DirectX algorithm to scale the sprite size
out float fDepth, // Flat sprite depth
out float4 oPos : POSITION0, // Projected sprite position
out float fDiameter : PSIZE, // Sprite size in pixels (DX point sprites are sized in px)
out float fSphereRadiusDepth : TEXCOORDn // Radius of the sphere in depth coords
{
...
// Normal projection
oPos = mul(vPos, g_mWorldViewProj);

// DX depth (of the flat billboarded point sprite)
fDepth = oPos.z / oPos.w;

// Also scale the sprite size - DX specifies a point sprite's size in pixels.
// One (old) algorithm is in http://msdn.microsoft.com/en-us/library/windows/desktop/bb147281(v=vs.85).aspx
fDXScale = ...;

// Finally, the key: what's the depth coord to use for the thickness of the sphere?

...
}
``````
``````float CalculateSphereDepth(float4 vPos, float fPointRadius, float fSphereCenterDepth, float fDXScale) {
// Calculate sphere depth.  Do this by calculating a point on the
// far side of the sphere, ie cast a ray from the eye, through the
// point sprite vertex (the sphere center) and extend it by the radius
// of the sphere
// The difference in depths between the sphere center and the sphere
// edge is then used to write out sphere 'depth' on the sprite.
float4 vRayDir = vPos - g_vecEyePos;
float fLength = length(vRayDir);
vRayDir = normalize(vRayDir);
fLength = fLength + vPointRadius; // Distance from eye through sphere center to edge of sphere

float4 oSphereEdgePos = g_vecEyePos + (fLength * vRayDir); // Point on the edge of the sphere
oSphereEdgePos.w = 1.0;
oSphereEdgePos = mul(oSphereEdgePos, g_mWorldViewProj); // Project it

// DX depth calculation of the projected sphere-edge point
const float fSphereEdgeDepth = oSphereEdgePos.z / oSphereEdgePos.w;
float fSphereRadiusDepth = fSphereCenterDepth - fSphereEdgeDepth; // Difference between center and edge of sphere
fSphereRadiusDepth *= fDXScale; // Account for sphere scaling

}
``````
``````void SpherePS(
...
float fSpriteDepth : TEXCOORD0,
out float4 oFragment : COLOR0,
out float fSphereDepth : DEPTH0
)
{
float fCircleDist = ...; // See example code in the question
// 0-1 value from the center of the sprite, use clip to form the sprite into a circle
clip(fCircleDist);

fSphereDepth = fSpriteDepth + (fCircleDist * fSphereRadiusDepth);

// And calculate a pixel color
oFragment = ...; // Add lighting etc here
}
``````

## Get all pixel array inside circle

By : mmd378
Date : March 29 2020, 07:55 AM
should help you out I have this: , You are looking for the following set of pixels:
code :
``````List<int> indices = new List<int>();

for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
double dx = x - m1;
double dy = y - m2;
double distanceSquared = dx * dx + dy * dy;

{
}
}
}
``````

## running on every pixel inside a circle

By : user3029831
Date : March 29 2020, 07:55 AM
this will help You need to create an imaginary grid, or rather a grid that is only useful in that it will help you solve the problem at hand. This is the grid that you will assign all the bitmaps to a position on, imagining that the circle's center is to be located at (0,0).
You then use a little math

## calculate pixel coordinates for 8 equidistant points on a circle

By : Karlo Huerta Kayser
Date : March 29 2020, 07:55 AM
help you fix your problem I have a circle centred at 0 with radius 80. How using python do I calculate the coordinates for 8 equidistant points around the circumference of the circle?
code :
``````r = 80
numPoints = 8.0
points = []
for index in range(numPoints):
points.append([r*math.cos((index*2*math.pi)/numPoints),r*math.sin((index*2*math.pi)/numPoints)])
return points
``````
``````r = 80
numPoints = 8
points = []
x = (r*math.sqrt(2))/2
points = [[0,r],[x,x],[r,0],[-x,x],[-r,0],[-x,-x],[0,-r],[x,-x]]
print points
``````

## How to create a white border circle having white exclamation mark inside a box having a yellow background in html/css?

By : garik
Date : March 29 2020, 07:55 AM
like below fixes the issue No need to use an image here, it's easier, faster, more scalable and flexible to use a pseudo element like ::before here:
code :
``````.my-paragraph-style {
background: #EABB27;
line-height: 1.4;
position: relative;
font-family: arial, helvetica, sans-serif;
color: white;
font-weight: bold;
font-size: 14px;
max-width: 300px;
}
.my-paragraph-style::before {
display: block;
position: absolute;
left: 20px;
top: 23px;
content: "!";
``<p class="my-paragraph-style">List your dependents and enter their personal information. Pay close attention to information regarding your spouse’s smoking habits.</p>`` 