[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 8# pd1


    虽然颜色不一样
但都是在下半部分有色块,颜色数量10左右吧
不知道能不能这样,只统计下半部分所有像素的颜色,按颜色占比来判断

TOP

实践一下应该可以找出花的图
  1. #@&cls&powershell "type '%~f0'|out-string|iex"&pause&exit
  2. Add-Type -AssemblyName System.Drawing
  3. $cp = New-Object CodeDom.Compiler.CompilerParameters
  4. $cp.ReferencedAssemblies.Add([Reflection.Assembly]::GetAssembly([Drawing.Image]).Location) >$null
  5. $cp.ReferencedAssemblies.Add([Reflection.Assembly]::GetAssembly([Linq.Enumerable]).Location) >$null
  6. $cp.CompilerOptions ='/unsafe'
  7. Add-Type -CompilerParameters $cp -TypeDefinition @'
  8. using System;
  9. using System.Drawing;
  10. using System.Drawing.Imaging;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. public class test
  14. {
  15.     unsafe public static int main(string f)
  16.     {
  17. Bitmap bitmap = new Bitmap(@f);
  18. int width = bitmap.Width;
  19. int height = bitmap.Height;
  20. int h = height/2;
  21. BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, h, width, height-h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
  22. byte* p = (byte*)(IntPtr)bitmapData.Scan0;
  23. Dictionary<int, int> b = new Dictionary<int, int>();
  24. for (int i = 0; i < width * (height-h) * 4; i+=4)
  25. {
  26.     int c = (p[i+3] << 24) | (p[i+2] << 16) | (p[i+1] << 8) | p[i];
  27.             b[c] = b.ContainsKey(c) ? b[c] + 1 : 1;
  28. }
  29. bitmap.UnlockBits(bitmapData);
  30. var d = b.OrderBy(x => x.Value).Select(x => x.Value).ToArray();
  31. return width*h/(d[d.Length-1]) < 30 ? 1 : 0;
  32.     }
  33. }
  34. '@
  35. dir *.jpg|%{if([test]::main($_.FullName)){$_.fullname}}
复制代码
1

评分人数

TOP

  1. #@&cls&powershell "type '%~f0'|out-string|iex"&pause&exit
  2. Add-Type -AssemblyName System.Drawing
  3. $cp = New-Object CodeDom.Compiler.CompilerParameters
  4. $cp.ReferencedAssemblies.Add([Reflection.Assembly]::GetAssembly([Drawing.Image]).Location) >$null
  5. $cp.ReferencedAssemblies.Add([Reflection.Assembly]::GetAssembly([Linq.Enumerable]).Location) >$null
  6. $cp.CompilerOptions ='/unsafe'
  7. Add-Type -CompilerParameters $cp -TypeDefinition @'
  8. using System;
  9. using System.Drawing;
  10. using System.Drawing.Imaging;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. public class test
  14. {
  15.     unsafe public static int main(string f)
  16.     {
  17. Bitmap bitmap = new Bitmap(@f);
  18. int width = bitmap.Width;
  19. int height = bitmap.Height;
  20. int h = height/2;
  21. BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, h, width, height-h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
  22. byte* p = (byte*)(IntPtr)bitmapData.Scan0;
  23. Dictionary<int, int> b = new Dictionary<int, int>();
  24. for (int i = 0; i < width * (height-h) * 4; i+=4)
  25. {
  26.     int c = (p[i+3] << 24) | (p[i+2] << 16) | (p[i+1] << 8) | p[i];
  27.             b[c] = b.ContainsKey(c) ? b[c] + 1 : 1;
  28. }
  29. bitmap.UnlockBits(bitmapData);
  30.         bitmap.Dispose();
  31. var d = b.OrderBy(x => x.Value).Select(x => x.Value).ToArray();
  32. return width*h/(d[d.Length-1]) < 30 ? 1 : 0;
  33.     }
  34. }
  35. '@
  36. mkdir 123
  37. $a=dir *.jpg|%{if([test]::main($_.FullName)){move $_.fullname '123'}}
复制代码
2

评分人数

TOP

返回列表