1

how can I create a program that can handle this pictures in a specific folder? The program must be able to calculate the relative ratio of the volume of the 3 cores among themselves based on the determined image data.

Finally, the relative ratio should get displayed via a dialogue

Exp: enter image description here

  • Z25777766_Depth.bmp
  • Z25777766Leer_Depth.bmp
  • Z25777783_Depth.bmp
  • Z25777783Leer_Depth.bmp
  • Z25777796_Depth.bmp
  • Z25777796Leer_Depth.bmp

There are always 2 pictures belonging together. They differ only by the word "Leer" in the file name.

Always the first picture is a 3-dimensional picture of a core in a selection station, the second 3- dimensional picture (“Leer”) shows the empty selection place. ´

class ImageProcessing

    {
        private string _index;

        public ImageProcessing(string text)
        {
            _index = text;
        }
        public void OpenAbitmap()
        {
            Bitmap picture = new Bitmap(@"C:\Users\Desktop\A\" + _index.ToString() + ".bmp");
        }
    }
MokiNex
  • 857
  • 1
  • 8
  • 21
  • You should use `Path.Combine` when creating a path `Path.Combine("C:\Users\Desktop\A", _index.ToString() + ".bmp");` –  Nov 06 '18 at 12:53
  • Your second attempt to ask a question still didn't got better. What exact problem do you have? Do you want to enumerate all files in folder and read them to some sort of collection? Or do you want to read them in some sort of groups? – Renatas M. Nov 06 '18 at 13:00
  • @Reniuz want to read the images file then based on the name if there is `Leer` means something missing in pictures so if 6 images 2 of them has the word `Leer` my output will give: per 6 pictures you have 66.66 % full images its kind of statistic – MokiNex Nov 06 '18 at 13:07
  • Do you want to count the files that contain 'Leer' in their names? – roozbeh S Nov 06 '18 at 13:09
  • @roozbehS yes exactly – MokiNex Nov 06 '18 at 13:12
  • [Get all file names](https://stackoverflow.com/questions/7140081/how-to-get-only-filenames-within-a-directory-using-c) then check how many of them [contains](https://learn.microsoft.com/en-us/dotnet/api/system.string.contains?view=netframework-4.7.2) `Leer` in the name. And your question is good example of [XY problem](https://en.wikipedia.org/wiki/XY_problem) – Renatas M. Nov 06 '18 at 13:15

1 Answers1

1

You can count the files as below:

int imageCount = Directory.GetFiles("path of directory").Count();
int fullImageCount = Directory.GetFiles("path of directory").Count(x=>!x.Contains("Leer"));
double percent = 100.0 * (double)fullImageCount / (double)imageCount;

then output it as below:

Console.WriteLine(String.Format("per {0} pictures you have {1} % full images", imageCount, percent);
roozbeh S
  • 1,084
  • 1
  • 9
  • 16