DevioLabавтоматичне керування капіталом
ПРАЦЮЄ 24/7
КРИПТОВАЛЮТИ · АКЦІЇ · 10 БІРЖ

Портфель, який керується автоматично

DevioLab підбирає стратегії, відстежує ринки та автоматизує купівлю і продаж активів. Кількість доступних криптовалют, акцій і торгових можливостей зростає щодня.

10підключених біржCrypto + Stocksв одному портфелі24/7автоматичний контроль

Графічні фільтри та їх використання

Інформація про навчальний заклад

ВУЗ:
Національний університет Львівська політехніка
Інститут:
Інститут комп’ютерних наук та інформаційних технологій
Факультет:
Комп’ютерні науки
Кафедра:
Кафедра програмного забезпечення

Інформація про роботу

Рік:
2007
Тип роботи:
Лабораторна робота
Предмет:
Методи та засоби комп’ютерних інформаційних технологій
Група:
КН
Коротко про документ

Про що ця робота

У цій лабораторній роботі студенти ознайомлюються з компонентом TImage, його властивостями та методами. Також вивчається представлення графіки у форматах BMP та JPEG із застосуванням фільтрів.

У роботі розглядаються

  • Графічні фільтри
  • Компонент TImage
  • Формати BMP та JPEG
  • Обробка зображень
  • Алгоритми розмиття
  • Мова програмування Pascal

Зміст і розділи

  1. Тема
  2. Мета
  3. Unit_1
  4. Unit_2
  5. Вікно1
  6. Висновок
Для кого:Студенти технічних спеціальностей вищих навчальних закладів
Викладачі:Викладач кафедри

Ключові поняття

TImageBMPJPEGпіксельполотнорозмиттяядромасивпроцедура

Частина тексту файла (без зображень, графіків і формул):

МІНІСТЕРСТВО ОСВІТИ І НАУКИ УКРАЇНИ Національний університет Львівська політехніка Кафедра ПЗ До лабораторної роботи №4 З курсу “Методи та засоби КІТ” На тему: Графічні фільтри та їх використання. Львів – 2007 Тема: Графічні фільтри та їх використання. Мета: Ознайомитись з компонентом TImage, вивчити властивості компонента, та його методи,ознайомитися з представленням графіки в форматі bmp та jpeg.  UNIT_1 procedure TForm1.FormShow(Sender: TObject); begin JpegIm := TJpegImage.Create; MyImage := TBitmap.Create; {image1.Width:=form1.Width-62; image1.height:=form1.height-1; Image1.Canvas.Pixels[Image1.Width,Image1.Height]:=clCaptionText; image1.Width:=284; image1.height:=201;} end; procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Image1.Cursor:=crCross; if ssLeft in Shift then begin Image1.Canvas.Pixels[x,y]:=colordialog1.Color; panel2.Color:=Image1.Canvas.Pixels[x,y]; end; if SpeedButton4.Down then if ssLeft in Shift then begin x1:=x; y1:=y; end; if SpeedButton1.Down then begin Image1.Canvas.Pen.Width:=15; if ssLeft in Shift then Image1.Canvas.Pixels[x,y]:=Image1.Canvas.Brush.Color; end; if SpeedButton3.Down then Image1.Canvas.Brush.Color:=ColorDialog1.Color; //Image1. end; procedure TForm1.SpeedButton9Click(Sender: TObject); begin if colordialog1.Execute then MyImage.Canvas.Pen.Color:=colordialog1.Color; end; procedure TForm1.SpeedButton7Click(Sender: TObject); begin if OpenDialog1.Execute then JpegIm.LoadFromFile(OpenDialog1.FileName); MyImage.Assign(JpegIm); image1.Canvas.Brush.Color := ClWhite; image1.Canvas.FillRect(Canvas.ClipRect); image1.Canvas.Draw(0,0,MyImage); end; procedure TForm1.SpeedButton8Click(Sender: TObject); begin if SaveDialog1.Execute then image1.Picture.SaveToFile(SaveDialog1.FileName); end; procedure TForm1.Button1Click(Sender: TObject); begin //image1.Canvas. end; procedure TForm1.SpeedButton11MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin lmbshift:=1; while lmbshift=1 do begin image1.Width:=image1.Width+1; image1.Height:=image1.Height+1; Image1.Canvas.Pixels[Image1.Width,Image1.Height]:=clCaptionText; sleep(50); application.ProcessMessages; end; end; procedure TForm1.SpeedButton11MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin lmbshift:=0; SpeedButton11.Repaint; end; procedure TForm1.SpeedButton10MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin lmbshift:=1; while lmbshift=1 do begin image1.Width:=image1.Width-1; image1.Height:=image1.Height-1; Image1.Canvas.Pixels[Image1.Width,Image1.Height]:=clCaptionText; sleep(50); application.ProcessMessages; end; end; procedure TForm1.SpeedButton10MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin lmbshift:=0; SpeedButton10.Repaint; end; procedure TForm1.N1Click(Sender: TObject); begin form2.ShowModal; end; UNIT_2 interface uses Windows, Graphics; type PRGBTriple = ^TRGBTriple; TRGBTriple = packed record b: byte; //краще для використання ныж rgbtBlue... g: byte; r: byte; end; PRow = ^TRow; TRow = array[0..1000000] of TRGBTriple; PPRows = ^TPRows; TPRows = array[0..1000000] of PRow; const MaxKernelSize = 100; type TKernelSize = 1..MaxKernelSize; TKernel = record Size: TKernelSize; Weights: array[-MaxKernelSize..MaxKernelSize] of single; end; procedure GBlur(theBitmap: TBitmap; radius: double); implementation uses SysUtils; procedure MakeGaussianKernel(var K: TKernel; radius: double; MaxData, DataGranularity: double); var j: integer; temp, delta: double; KernelSize: TKernelSize; begin for j := Low(K.Weights) to High(K.Weights) do begin temp := j / radius; K.Weights[j] := exp(-temp * temp / 2); end; //делаем так, чтобы sum(Weights) = 1: temp := 0; for j := Low(K.Weights) to High(K.Weights) do temp := temp + K.Weights[j]; for j := Low(K.Weights) to High(K.Weights) do K.Weights[j] := K.Weights[j] / temp; KernelSize := MaxKernelSize; delta := DataGranularity / (2 * MaxData); temp := 0; while (temp < delta) and (KernelSize > 1) do begin temp := temp + 2 * K.Weights[KernelSize]; dec(KernelSize); end; K.Size := KernelSize; temp := 0; for j := -K.Size to K.Size do temp := temp + K.Weights[j]; for j := -K.Size to K.Size do K.Weights[j] := K.Weights[j] / temp; end; function TrimInt(Lower, Upper, theInteger: integer): integer; begin if (theInteger <= Upper) and (theInteger >= Lower) then result := theInteger else if theInteger > Upper then result := Upper else result := Lower; end; function TrimReal(Lower, Upper: integer; x: double): integer; begin if (x < upper) and (x >= lower) then result := trunc(x) else if x > Upper then result := Upper else result := Lower; end; procedure BlurRow(var theRow: array of TRGBTriple; K: TKernel; P: PRow); var j, n, LocalRow: integer; tr, tg, tb: double; //tempRed и др. w: double; begin for j := 0 to High(theRow) do begin tb := 0; tg := 0; tr := 0; for n := -K.Size to K.Size do begin w := K.Weights[n]; with theRow[TrimInt(0, High(theRow), j - n)] do begin tb := tb + w * b; tg := tg + w * g; tr := tr + w * r; end; end; with P[j] do begin b := TrimReal(0, 255, tb); g := TrimReal(0, 255, tg); r := TrimReal(0, 255, tr); end; end; Move(P[0], theRow[0], (High(theRow) + 1) * Sizeof(TRGBTriple)); end; procedure GBlur(theBitmap: TBitmap; radius: double); var Row, Col: integer; theRows: PPRows; K: TKernel; ACol: PRow; P: PRow; begin if (theBitmap.HandleType <> bmDIB) or (theBitmap.PixelFormat <> pf24Bit) then raise exception.Create('GBlur може працювати тыльки з 24 бітнимим зображеннями'); MakeGaussianKernel(K, radius, 255, 1); GetMem(theRows, theBitmap.Height * SizeOf(PRow)); GetMem(ACol, theBitmap.Height * SizeOf(TRGBTriple)); for Row := 0 to theBitmap.Height - 1 do theRows[Row] := theBitmap.Scanline[Row]; //розмиваєм кожну стрічку: P := AllocMem(theBitmap.Width * SizeOf(TRGBTriple)); for Row := 0 to theBitmap.Height - 1 do BlurRow(Slice(theRows[Row]^, theBitmap.Width), K, P); ReAllocMem(P, theBitmap.Height * SizeOf(TRGBTriple)); for Col := 0 to theBitmap.Width - 1 do begin for Row := 0 to theBitmap.Height - 1 do ACol[Row] := theRows[Row][Col]; BlurRow(Slice(ACol^, theBitmap.Height), K, P) for Row := 0 to theBitmap.Height - 1 do theRows[Row][Col] := ACol[Row]; end; FreeMem(theRows); FreeMem(ACol); ReAllocMem(P, 0); end; end. Вікнo1:  Інвертоване зображення  Розмите зображення  Висновок: На цій лабораторній роботі я ознайомився із компонентом TImage, вивчив методи та властивості, ознайомився з представленням графіки в форматі bmp та jpeg.
Допоможи студентському архіву

Ми допомогли тобі — допоможи наступному студенту

Файл ще не обрано

Оголошення від адміністратора

Антиботан аватар за замовчуванням

Подякувати Студентському архіву довільною сумою

Admin

26.02.2023 12:38

Дякуємо, що користуєтесь нашим архівом!