Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DN2_Haar.src.Statitiscs
- {
- class Blokovnost
- {
- public static double Calc(string imageName)
- {
- // Read images
- Bitmap bmp = new Bitmap(imageName);
- LockBitmap lockBitmap = new LockBitmap(bmp);
- lockBitmap.LockBits();
- int M = lockBitmap.Width;
- int N = lockBitmap.Height;
- double result = 0.0;
- int maxM = (int)Math.Floor(M / 8.0);
- for (int i = 0; i < maxM; i++)
- {
- for (int j = 0; j < N; j++)
- {
- Color c1 = lockBitmap.GetPixel(i * 8, j);
- Color c2 = lockBitmap.GetPixel(i * 8 + 1, j);
- result += Math.Abs(c1.R - c2.R);
- }
- }
- int maxN = (int)Math.Floor(N / 8.0);
- for (int j = 0; j < maxN; j++)
- {
- for (int i = 0; i < M; i++)
- {
- Color c1 = lockBitmap.GetPixel(i, j * 8);
- Color c2 = lockBitmap.GetPixel(i, j * 8 + 1);
- result += Math.Abs(c1.R - c2.R);
- }
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement