C# 如何从给定文件夹加载图像
我如何创建一个程序来处理特定文件夹中的这些图片?该程序必须能够根据确定的图像数据计算3个岩芯体积之间的相对比例 最后,应通过对话显示相对比率 经验: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”一词 始终第一张图片是
- Z25777766_Depth.bmp
- Z25777766Leer_Depth.bmp
- Z25777783_Depth.bmp
- Z25777783Leer_Depth.bmp
- Z25777796_Depth.bmp
- Z25777796Leer_Depth.bmp
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
方法