Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从给定文件夹加载图像_C#_Bitmap - Fatal编程技术网

C# 如何从给定文件夹加载图像

C# 如何从给定文件夹加载图像,c#,bitmap,C#,Bitmap,我如何创建一个程序来处理特定文件夹中的这些图片?该程序必须能够根据确定的图像数据计算3个岩芯体积之间的相对比例 最后,应通过对话显示相对比率 经验: Z25777766_Depth.bmp Z25777766Leer_Depth.bmp Z25777783_Depth.bmp Z25777783Leer_Depth.bmp Z25777796_Depth.bmp Z25777796Leer_Depth.bmp 总有两张照片属于一起。它们的区别只是文件名中的“Leer”一词 始终第一张图片是

我如何创建一个程序来处理特定文件夹中的这些图片?该程序必须能够根据确定的图像数据计算3个岩芯体积之间的相对比例

最后,应通过对话显示相对比率

经验:

  • Z25777766_Depth.bmp
  • Z25777766Leer_Depth.bmp
  • Z25777783_Depth.bmp
  • Z25777783Leer_Depth.bmp
  • Z25777796_Depth.bmp
  • Z25777796Leer_Depth.bmp
总有两张照片属于一起。它们的区别只是文件名中的“Leer”一词

始终第一张图片是选择站中的核心的三维图片,第二张图片是3- 三维图片(“Leer”)显示空的选择位置。`

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");
        }
    }

您可以按如下方式计算这些文件:

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;
Console.WriteLine(String.Format("per {0} pictures you have {1} % full images", imageCount, percent);
然后按如下方式输出:

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;
Console.WriteLine(String.Format("per {0} pictures you have {1} % full images", imageCount, percent);

创建路径时应使用
Path.Combine
路径.Combine(“C:\Users\Desktop\a”,“u index.ToString()+”.bmp”)您第二次尝试提问的情况仍然没有好转。你到底有什么问题?是否要枚举文件夹中的所有文件并将其读入某种集合?或者你想以某种形式阅读它们?@Reniuz想阅读图像文件,然后根据名称,如果有
Leer
意味着图片中缺少某些内容,那么如果6张图像中有2张图像有
Leer
这个词,我的输出将给出:每6张图像,你有66.66%的完整图像,其类型的统计数据你想数一数吗名称中包含“Leer”的文件?@roozbehS是的。当我运行you方法时,它的say
非发票成员“Directory”不能像方法一样使用
@MokiNex抱歉,我忘了键入
GetFiles
方法