misc fixes
This commit is contained in:
@@ -17,20 +17,22 @@ public class Program {
|
|||||||
static List<SDFData> SDFs = new();
|
static List<SDFData> SDFs = new();
|
||||||
static List<Vector3[,]> Gradients = new();
|
static List<Vector3[,]> Gradients = new();
|
||||||
static readonly SdfKernels kernels = new();
|
static readonly SdfKernels kernels = new();
|
||||||
|
static uint width;
|
||||||
|
static uint height;
|
||||||
|
|
||||||
static void ConsoleUpdateLine(string s) => Console.Write("\r" + s);
|
static void ConsoleUpdateLine(string s) => Console.Write("\r" + s);
|
||||||
|
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
Console.WriteLine("Reading images...");
|
Console.WriteLine("Reading images...");
|
||||||
|
|
||||||
|
/*
|
||||||
var imagesPath = "images";
|
var imagesPath = "images";
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
var pixels = ImageUtil.LoadImage<Vector3>($"./{imagesPath}{Path.DirectorySeparatorChar}{i + 1:00}.png");
|
var pixels = ImageUtil.LoadImage<Vector3>($"./{imagesPath}{Path.DirectorySeparatorChar}{i + 1:00}.png");
|
||||||
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
var pixels = ImageUtil.LoadImage<Vector3>($"./sphereempty.png");
|
var pixels = ImageUtil.LoadImage<Vector3>($"./sphereempty.png");
|
||||||
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
||||||
pixels = ImageUtil.LoadImage<Vector3>($"./spherehalf.png");
|
pixels = ImageUtil.LoadImage<Vector3>($"./spherehalf.png");
|
||||||
@@ -39,9 +41,7 @@ public class Program {
|
|||||||
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
||||||
pixels = ImageUtil.LoadImage<Vector3>($"./spherefull.png");
|
pixels = ImageUtil.LoadImage<Vector3>($"./spherefull.png");
|
||||||
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//check if all the images in Images are the same resolution
|
//check if all the images in Images are the same resolution
|
||||||
if (Images.Select(img => (img.Width, img.Height)).Distinct().Count() > 1) {
|
if (Images.Select(img => (img.Width, img.Height)).Distinct().Count() > 1) {
|
||||||
Console.WriteLine("Error: Not all images have the same resolution.");
|
Console.WriteLine("Error: Not all images have the same resolution.");
|
||||||
@@ -56,14 +56,13 @@ public class Program {
|
|||||||
Images[i].Pixels[x, y].Z = MathF.Min(Images[i - 1].Pixels[x, y].Z + Images[i].Pixels[x, y].X, MAX);
|
Images[i].Pixels[x, y].Z = MathF.Min(Images[i - 1].Pixels[x, y].Z + Images[i].Pixels[x, y].X, MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Images[i].Pixels.SaveImage($"./Sum{i}.png");
|
Images[i].Pixels.SaveImage($"./Sum{i}.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Creating masks...");
|
Console.WriteLine("Creating masks...");
|
||||||
//for each image pair, create a mask
|
//for each image pair, create a mask
|
||||||
var width = (uint)Images[0].Width;
|
width = (uint)Images[0].Width;
|
||||||
var height = (uint)Images[0].Height;
|
height = (uint)Images[0].Height;
|
||||||
for (int i = 0; i < Images.Count; i++) {
|
for (int i = 0; i < Images.Count; i++) {
|
||||||
ImageMasks.Add(new(SelfMask(Images[i].Pixels, width, height), Images[i], new()));
|
ImageMasks.Add(new(SelfMask(Images[i].Pixels, width, height), Images[i], new()));
|
||||||
if (i < Images.Count - 1) {
|
if (i < Images.Count - 1) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public partial class SdfKernels {
|
|||||||
) {
|
) {
|
||||||
Vector2 pos = new((float)index.X / width, (float)index.Y / height);
|
Vector2 pos = new((float)index.X / width, (float)index.Y / height);
|
||||||
float minDist = 2f;
|
float minDist = 2f;
|
||||||
int count = edges.IntExtent.X;
|
int count = edges.IntExtent.Size;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Vector2 edgeNrm = new (edges[i].X/width, edges[i].Y/height);
|
Vector2 edgeNrm = new (edges[i].X/width, edges[i].Y/height);
|
||||||
@@ -69,4 +69,5 @@ public partial class SdfKernels {
|
|||||||
|
|
||||||
sdf[index] = new(minDist);
|
sdf[index] = new(minDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@ public partial class SdfKernels {
|
|||||||
.OpenCL()
|
.OpenCL()
|
||||||
.Cuda()
|
.Cuda()
|
||||||
.CPU()
|
.CPU()
|
||||||
|
.Math(MathMode.Fast32BitOnly)
|
||||||
);
|
);
|
||||||
|
|
||||||
Console.WriteLine("Reading available accelerators (CUDA only)...");
|
Console.WriteLine("Reading available accelerators (CUDA only)...");
|
||||||
|
|||||||
Reference in New Issue
Block a user