OSDN Git Service

わかりやすく
authoryamat0jp <yamat0jp@yahoo.co.jp>
Fri, 1 Jun 2018 09:55:55 +0000 (18:55 +0900)
committeryamat0jp <yamat0jp@yahoo.co.jp>
Fri, 1 Jun 2018 09:55:55 +0000 (18:55 +0900)
平坦かに付け加えた

grayconversion/Unit1.dfm
grayconversion/Unit1.pas

index c3eb096..4ed52fd 100644 (file)
@@ -2,7 +2,7 @@ object Form1: TForm1
   Left = 0
   Top = 0
   Caption = 'Form1'
-  ClientHeight = 299
+  ClientHeight = 461
   ClientWidth = 635
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
@@ -15,7 +15,7 @@ object Form1: TForm1
   OnDestroy = FormDestroy
   DesignSize = (
     635
-    299)
+    461)
   PixelsPerInch = 96
   TextHeight = 13
   object Image1: TImage
@@ -2087,6 +2087,12 @@ object Form1: TForm1
     Proportional = True
     Stretch = True
   end
+  object PaintBox1: TPaintBox
+    Left = 88
+    Top = 280
+    Width = 256
+    Height = 150
+  end
   object Button1: TButton
     Left = 528
     Top = 32
@@ -2107,6 +2113,24 @@ object Form1: TForm1
     TabOrder = 1
     OnClick = Button2Click
   end
+  object RadioButton1: TRadioButton
+    Left = 424
+    Top = 281
+    Width = 113
+    Height = 17
+    Caption = #20803#30011#20687
+    Checked = True
+    TabOrder = 2
+    TabStop = True
+  end
+  object RadioButton2: TRadioButton
+    Left = 432
+    Top = 304
+    Width = 113
+    Height = 17
+    Caption = #22793#25563#30011#20687
+    TabOrder = 3
+  end
   object OpenPictureDialog1: TOpenPictureDialog
     Left = 536
     Top = 144
index 9804ee6..7dc74f5 100644 (file)
@@ -15,6 +15,9 @@ type
     Image2: TImage;
     OpenPictureDialog1: TOpenPictureDialog;
     Button2: TButton;
+    PaintBox1: TPaintBox;
+    RadioButton1: TRadioButton;
+    RadioButton2: TRadioButton;
     procedure Button1Click(Sender: TObject);
     procedure Button2Click(Sender: TObject);
     procedure FormCreate(Sender: TObject);
@@ -46,7 +49,7 @@ var
   nx, ny, i, j, k, small, big: integer;
   kk: Byte;
   ss, mean: integer;
-  hist: array [0 .. GMAX] of integer;
+  hist, buffer: array [0 .. GMAX] of integer;
   nmove, cnt: array [0 .. GMAX, 0 .. GMAX] of integer;
   col: TRGBTriple;
   p: array of TRGBTriple;
@@ -68,6 +71,7 @@ begin
       inc(hist[k]);
     end;
   end;
+  buffer := hist;
   for i := 0 to GMAX do
     for j := 0 to GMAX do
     begin
@@ -148,6 +152,16 @@ begin
     end;
   end;
   Image2.Picture.Bitmap.Assign(bmp);
+  PaintBox1.Canvas.Rectangle(0, 0, PaintBox1.Width, PaintBox1.Height);
+  for i := 0 to GMAX do
+    with PaintBox1 do
+    begin
+      Canvas.MoveTo(i, Height);
+      if RadioButton1.Checked = true then
+        Canvas.LineTo(i, buffer[i])
+      else
+        Canvas.LineTo(i, Height - hist[i]);
+    end;
 end;
 
 procedure TForm1.FormCreate(Sender: TObject);