【问题标题】:How to load images from given folder如何从给定文件夹加载图像
【发布时间】:2018-11-06 12:46:46
【问题描述】:

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

最后,相对比例应该通过对话框显示

经验:

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

总是有 2 张图片属于一起。它们的区别仅在于文件名中的“Leer”一词。

始终第一张图片是选择站中核心的 3 维图片,第二张 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");
        }
    }

【问题讨论】:

  • 创建路径时应该使用Path.CombinePath.Combine("C:\Users\Desktop\A", _index.ToString() + ".bmp");
  • 您第二次尝试提问仍然没有好转。你有什么确切的问题?你想枚举文件夹中的所有文件并将它们读入某种集合吗?或者您想分几组阅读它们?
  • @Reniuz 想要读取图像文件然后根据名称如果有 Leer 意味着图片中缺少某些内容,因此如果 6 张图像中有 2 张带有单词 Leer 我的输出将给出:每 6 张图片,您有 66.66 % 的完整图片,这是一种统计数据
  • 您要统计名称中包含“Leer”的文件吗?
  • @roozbehS 是的

标签: c# bitmap


【解决方案1】:

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

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

【讨论】:

  • 当我运行你的方法时,它说Non-invocable member 'Directory' cannot be used like a method
  • @MokiNex 抱歉我忘记输入GetFiles 方法
猜你喜欢
  • 2019-12-09
  • 2012-07-28
  • 2012-08-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-07
  • 1970-01-01
相关资源
最近更新 更多