first commit
This commit is contained in:
commit
a1f8a38d73
158 files changed
+28314
No files matched your search
@@ -0,0 +1,7 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UEstatisticaCor.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
@@ -0,0 +1,24 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UEstatisticaCor.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
|
||||
void UEstatisticaCor::setCor(int cor)
|
||||
{
|
||||
this.cor = cor;
|
||||
}
|
||||
int UEstatisticaCor::getCor()
|
||||
{
|
||||
return cor;
|
||||
}
|
||||
void UEstatisticaCor::setQtd(int qtd)
|
||||
{
|
||||
this.qtd = qtd;
|
||||
}
|
||||
int UEstatisticaCor::getQtd()
|
||||
{
|
||||
return qtd;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UEstatisticaCor.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
UEstatisticaCor::UEstatisticaCor()
|
||||
{
|
||||
|
||||
}
|
||||
void UEstatisticaCor::setCor(int cor)
|
||||
{
|
||||
this->cor = cor;
|
||||
}
|
||||
int UEstatisticaCor::getCor()
|
||||
{
|
||||
return cor;
|
||||
}
|
||||
void UEstatisticaCor::setQtd(int qtd)
|
||||
{
|
||||
this->qtd = qtd;
|
||||
}
|
||||
int UEstatisticaCor::getQtd()
|
||||
{
|
||||
return qtd;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UEstatisticaCor.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
UEstatisticaCor::UEstatisticaCor()
|
||||
{
|
||||
this ->cor = 0;
|
||||
this ->qtd = 0;
|
||||
}
|
||||
void UEstatisticaCor::setCor(int cor)
|
||||
{
|
||||
this->cor = cor;
|
||||
}
|
||||
int UEstatisticaCor::getCor()
|
||||
{
|
||||
return cor;
|
||||
}
|
||||
void UEstatisticaCor::setQtd(int qtd)
|
||||
{
|
||||
this->qtd = qtd;
|
||||
}
|
||||
int UEstatisticaCor::getQtd()
|
||||
{
|
||||
return qtd;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UEstatisticaCor.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
UEstatisticaCor::UEstatisticaCor()
|
||||
{
|
||||
this ->cor = 0;
|
||||
this ->qtd = 0;
|
||||
}
|
||||
void UEstatisticaCor::setCor(int cor)
|
||||
{
|
||||
this->cor = cor;
|
||||
}
|
||||
int UEstatisticaCor::getCor()
|
||||
{
|
||||
return cor;
|
||||
}
|
||||
void UEstatisticaCor::setQtd(int qtd)
|
||||
{
|
||||
this->qtd = qtd;
|
||||
}
|
||||
int UEstatisticaCor::getQtd()
|
||||
{
|
||||
return qtd;
|
||||
}
|
||||
void UEstatisticaCor::resetar()
|
||||
{
|
||||
this->cor = 0;
|
||||
this->qtd = 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UEstatisticaCorH
|
||||
#define UEstatisticaCorH
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UEstatisticaCorH
|
||||
#define UEstatisticaCorH
|
||||
//---------------------------------------------------------------------------
|
||||
public UEstatisticaCor
|
||||
{
|
||||
private:
|
||||
int cor;
|
||||
int qtd;
|
||||
public:
|
||||
void setCor(int cor);
|
||||
int getCor();
|
||||
void setQtd(int qtd);
|
||||
int getQtd();
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UEstatisticaCorH
|
||||
#define UEstatisticaCorH
|
||||
//---------------------------------------------------------------------------
|
||||
public class UEstatisticaCor
|
||||
{
|
||||
private:
|
||||
int cor;
|
||||
int qtd;
|
||||
public:
|
||||
void setCor(int cor);
|
||||
int getCor();
|
||||
void setQtd(int qtd);
|
||||
int getQtd();
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UEstatisticaCorH
|
||||
#define UEstatisticaCorH
|
||||
//---------------------------------------------------------------------------
|
||||
class UEstatisticaCor
|
||||
{
|
||||
private:
|
||||
int cor;
|
||||
int qtd;
|
||||
public:
|
||||
UEstatisticaCor();
|
||||
void setCor(int cor);
|
||||
int getCor();
|
||||
void setQtd(int qtd);
|
||||
int getQtd();
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UEstatisticaCorH
|
||||
#define UEstatisticaCorH
|
||||
//---------------------------------------------------------------------------
|
||||
class UEstatisticaCor
|
||||
{
|
||||
private:
|
||||
int cor;
|
||||
int qtd;
|
||||
public:
|
||||
UEstatisticaCor();
|
||||
void setCor(int cor);
|
||||
int getCor();
|
||||
void setQtd(int qtd);
|
||||
int getQtd();
|
||||
void resetar();
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,681 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
//gradX /= 8;
|
||||
//gradY /= 8;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int Lap;
|
||||
int matriz[3][3] = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
Lap = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
Lap += pixel * matriz[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
Lap /= 4;
|
||||
|
||||
aux = (int)(Lap);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,681 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
//gradX /= 8;
|
||||
//gradY /= 8;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int Lap;
|
||||
int matriz[3][3] = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
Lap = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
Lap += pixel * matriz[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
Lap /= 4;
|
||||
|
||||
aux = (int)(Lap);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,684 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,684 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,740 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvPrewittOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{-1, 0, 1}, {1, 0, 1}, {-1, 0, 1}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {0, 0, 0}, {1, 1, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Prewitt...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,740 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvPrewittOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}};
|
||||
int matrizY[3][3] = {{1, -2, 1}, {-2, 4, -2}, {1, -2, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Prewitt...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,740 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvPrewittOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {0, 0, 0}, {1, 1, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Prewitt...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,745 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvOnClose(TObject *Sender, TCloseAction &Action)
|
||||
{
|
||||
Action = caFree;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvPrewittOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {0, 0, 0}, {1, 1, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Prewitt...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,740 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvLaplacianoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, -1, 0}, {-1, 4, -1}, {0, -1, 0}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {-1, 8, -1}, {-1, -1, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Laplaciano...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvPrewittOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{-1, 0, 1}, {-1, 0, 1}, {-1, 0, 1}};
|
||||
int matrizY[3][3] = {{-1, -1, -1}, {0, 0, 0}, {1, 1, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro Prewitt...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,630 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UEstatisticaCor.h"
|
||||
#include <math.h>
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAlgoritmos::TFrmAlgoritmos(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmAlgoritmos->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMediaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvModaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int maior;
|
||||
int auxiliar[256];
|
||||
int aux;
|
||||
int pixelEscolhido;
|
||||
int diferenca;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando a moda...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
auxiliar[k] = 0;
|
||||
}
|
||||
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
if(!(c==j && l==i))
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
pixelEscolhido = pixel;
|
||||
maior = auxiliar[pixel];
|
||||
|
||||
for(int x=1; x< 256; x++)
|
||||
{
|
||||
if((pixel - x) >= 0)
|
||||
{
|
||||
if(auxiliar[pixel - x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel - x];
|
||||
pixelEscolhido = pixel - x;
|
||||
}
|
||||
}
|
||||
|
||||
if((pixel + x) < 256)
|
||||
{
|
||||
if(auxiliar[pixel + x] > maior)
|
||||
{
|
||||
maior = auxiliar[pixel + x];
|
||||
pixelEscolhido = pixel + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixelEscolhido, pixelEscolhido, pixelEscolhido);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
|
||||
int matrizY[3][3] = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 4;
|
||||
gradY /= 4;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAlgoritmos::EvRobertsOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{0, 0, -1}, {0, 1, 0}, {0, 0, 0}};
|
||||
int matrizY[3][3] = {{-1, 0, 0}, {0, 1, 0}, {0, 0, 0}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmAlgoritmos->Caption = "Aplicando o filtro de Roberts...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
//gradX /= 8;
|
||||
//gradY /= 8;
|
||||
|
||||
aux = (int) (sqrt(gradX * gradX + gradY * gradY));
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(aux, aux, aux);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmAlgoritmos->Caption = "Algoritmos de processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,337 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,338 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
OnClick = EvRobertsOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,338 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Algoritmos de processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
OnClick = EvRobertsOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,347 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Algoritmos de processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object btnRoberts: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
OnClick = EvRobertsOnClick
|
||||
end
|
||||
object btnLaplaciano: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Laplaciano'
|
||||
TabOrder = 2
|
||||
OnClick = EvLaplacianoOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,356 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Algoritmos de processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object btnRoberts: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
OnClick = EvRobertsOnClick
|
||||
end
|
||||
object btnLaplaciano: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Laplaciano'
|
||||
TabOrder = 2
|
||||
OnClick = EvLaplacianoOnClick
|
||||
end
|
||||
object btnPrewittOnClick: TButton
|
||||
Left = 9
|
||||
Top = 110
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Prewitt'
|
||||
TabOrder = 3
|
||||
OnClick = EvPrewittOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,357 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Algoritmos de processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object btnRoberts: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
OnClick = EvRobertsOnClick
|
||||
end
|
||||
object btnLaplaciano: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Laplaciano'
|
||||
TabOrder = 2
|
||||
OnClick = EvLaplacianoOnClick
|
||||
end
|
||||
object btnPrewittOnClick: TButton
|
||||
Left = 9
|
||||
Top = 110
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Prewitt'
|
||||
TabOrder = 3
|
||||
OnClick = EvPrewittOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,357 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Algoritmos de processamento de imagem digital.'
|
||||
ClientHeight = 631
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
OldCreateOrder = False
|
||||
Position = poMainFormCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object btnRoberts: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
OnClick = EvRobertsOnClick
|
||||
end
|
||||
object btnLaplaciano: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Laplaciano'
|
||||
TabOrder = 2
|
||||
OnClick = EvLaplacianoOnClick
|
||||
end
|
||||
object btnPrewittOnClick: TButton
|
||||
Left = 9
|
||||
Top = 110
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Prewitt'
|
||||
TabOrder = 3
|
||||
OnClick = EvPrewittOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,359 @@
|
||||
object FrmAlgoritmos: TFrmAlgoritmos
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'Algoritmos de processamento de imagem digital.'
|
||||
ClientHeight = 633
|
||||
ClientWidth = 1010
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIChild
|
||||
OldCreateOrder = False
|
||||
Position = poMainFormCenter
|
||||
Visible = True
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object grfOriginal: TChart
|
||||
Left = 228
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 0
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 622
|
||||
Top = 340
|
||||
Width = 380
|
||||
Height = 285
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object pnlImgOriginal: TPanel
|
||||
Left = 263
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 2
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlImgModificado: TPanel
|
||||
Left = 657
|
||||
Top = 10
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object pnlControles: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 210
|
||||
Height = 625
|
||||
TabOrder = 4
|
||||
object btnCarregarImagem: TButton
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 201
|
||||
Height = 25
|
||||
Caption = 'Carregar imagem...'
|
||||
TabOrder = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object pnlSegmentacao: TPanel
|
||||
Left = 4
|
||||
Top = 36
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 1
|
||||
object lblTituloSegmentacao: TLabel
|
||||
Left = 36
|
||||
Top = 5
|
||||
Width = 128
|
||||
Height = 13
|
||||
Caption = 'Algorimos de segmenta'#231#227'o'
|
||||
end
|
||||
object lblLimiar: TLabel
|
||||
Left = 12
|
||||
Top = 40
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object lblCanais: TLabel
|
||||
Left = 12
|
||||
Top = 70
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 50
|
||||
Top = 37
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnBinarizacao: TButton
|
||||
Left = 108
|
||||
Top = 35
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Binariza'#231#227'o'
|
||||
TabOrder = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 50
|
||||
Top = 66
|
||||
Width = 50
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnQuantizacao: TButton
|
||||
Left = 108
|
||||
Top = 64
|
||||
Width = 84
|
||||
Height = 25
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
TabOrder = 3
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TButton
|
||||
Left = 9
|
||||
Top = 100
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
TabOrder = 4
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pnlInfo: TPanel
|
||||
Left = 4
|
||||
Top = 472
|
||||
Width = 200
|
||||
Height = 141
|
||||
TabOrder = 2
|
||||
object lblAltura: TLabel
|
||||
Left = 133
|
||||
Top = 35
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object lblLargura: TLabel
|
||||
Left = 31
|
||||
Top = 35
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object lblTotalPixels: TLabel
|
||||
Left = 15
|
||||
Top = 85
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object lblPixelsProcessados: TLabel
|
||||
Left = 103
|
||||
Top = 85
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object lblTituloEstatisticas: TLabel
|
||||
Left = 73
|
||||
Top = 5
|
||||
Width = 54
|
||||
Height = 13
|
||||
Caption = 'Estat'#237'sticas'
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 103
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 5
|
||||
Top = 50
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 5
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 103
|
||||
Top = 100
|
||||
Width = 90
|
||||
Height = 21
|
||||
Alignment = taCenter
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object pnlPassaBaixa: TPanel
|
||||
Left = 4
|
||||
Top = 178
|
||||
Width = 200
|
||||
Height = 127
|
||||
TabOrder = 3
|
||||
object lblTituloPassaBaixa: TLabel
|
||||
Left = 44
|
||||
Top = 5
|
||||
Width = 111
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-baixa'
|
||||
end
|
||||
object btnMedia: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'M'#233'dia'
|
||||
TabOrder = 0
|
||||
OnClick = EvMediaOnClick
|
||||
end
|
||||
object btnMediana: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Mediana'
|
||||
TabOrder = 1
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object btnModa: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Moda'
|
||||
TabOrder = 2
|
||||
OnClick = EvModaOnClick
|
||||
end
|
||||
end
|
||||
object pnlPassaAlta: TPanel
|
||||
Left = 4
|
||||
Top = 306
|
||||
Width = 200
|
||||
Height = 164
|
||||
TabOrder = 4
|
||||
object lblTituloPassaAlta: TLabel
|
||||
Left = 48
|
||||
Top = 5
|
||||
Width = 103
|
||||
Height = 13
|
||||
Caption = 'Algoritmos passa-alta'
|
||||
end
|
||||
object btnSobel: TButton
|
||||
Left = 9
|
||||
Top = 35
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Sobel'
|
||||
TabOrder = 0
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
object btnRoberts: TButton
|
||||
Left = 9
|
||||
Top = 60
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Roberts'
|
||||
TabOrder = 1
|
||||
OnClick = EvRobertsOnClick
|
||||
end
|
||||
object btnLaplaciano: TButton
|
||||
Left = 9
|
||||
Top = 85
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Laplaciano'
|
||||
TabOrder = 2
|
||||
OnClick = EvLaplacianoOnClick
|
||||
end
|
||||
object btnPrewittOnClick: TButton
|
||||
Left = 9
|
||||
Top = 110
|
||||
Width = 183
|
||||
Height = 25
|
||||
Caption = 'Prewitt'
|
||||
TabOrder = 3
|
||||
OnClick = EvPrewittOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 600
|
||||
Top = 224
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,80 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmAlgoritmos : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TPanel *pnlImgOriginal;
|
||||
TImage *imgOriginal;
|
||||
TPanel *pnlImgModificado;
|
||||
TImage *imgAlteracao;
|
||||
TPanel *pnlControles;
|
||||
TButton *btnCarregarImagem;
|
||||
TPanel *pnlSegmentacao;
|
||||
TPanel *pnlInfo;
|
||||
TLabel *lblAltura;
|
||||
TEdit *edtAltura;
|
||||
TEdit *edtLargura;
|
||||
TLabel *lblLargura;
|
||||
TLabel *lblTotalPixels;
|
||||
TEdit *edtTotalPixels;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TLabel *lblPixelsProcessados;
|
||||
TLabel *lblTituloSegmentacao;
|
||||
TLabel *lblLimiar;
|
||||
TEdit *edtLimiar;
|
||||
TButton *btnBinarizacao;
|
||||
TLabel *lblCanais;
|
||||
TEdit *edtCanal;
|
||||
TButton *btnQuantizacao;
|
||||
TButton *btnEqualizacao;
|
||||
TPanel *pnlPassaBaixa;
|
||||
TLabel *lblTituloPassaBaixa;
|
||||
TButton *btnMedia;
|
||||
TButton *btnMediana;
|
||||
TButton *btnModa;
|
||||
TLabel *lblTituloEstatisticas;
|
||||
TPanel *pnlPassaAlta;
|
||||
TLabel *lblTituloPassaAlta;
|
||||
TButton *btnSobel;
|
||||
TButton *Button1;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvEqualizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvMediaOnClick(TObject *Sender);
|
||||
void __fastcall EvMedianaOnClick(TObject *Sender);
|
||||
void __fastcall EvModaOnClick(TObject *Sender);
|
||||
void __fastcall EvSobelOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmAlgoritmos(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmAlgoritmosH
|
||||
#define UFrmAlgoritmosH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmAlgoritmos : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TPanel *pnlImgOriginal;
|
||||
TImage *imgOriginal;
|
||||
TPanel *pnlImgModificado;
|
||||
TImage *imgAlteracao;
|
||||
TPanel *pnlControles;
|
||||
TButton *btnCarregarImagem;
|
||||
TPanel *pnlSegmentacao;
|
||||
TPanel *pnlInfo;
|
||||
TLabel *lblAltura;
|
||||
TEdit *edtAltura;
|
||||
TEdit *edtLargura;
|
||||
TLabel *lblLargura;
|
||||
TLabel *lblTotalPixels;
|
||||
TEdit *edtTotalPixels;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TLabel *lblPixelsProcessados;
|
||||
TLabel *lblTituloSegmentacao;
|
||||
TLabel *lblLimiar;
|
||||
TEdit *edtLimiar;
|
||||
TButton *btnBinarizacao;
|
||||
TLabel *lblCanais;
|
||||
TEdit *edtCanal;
|
||||
TButton *btnQuantizacao;
|
||||
TButton *btnEqualizacao;
|
||||
TPanel *pnlPassaBaixa;
|
||||
TLabel *lblTituloPassaBaixa;
|
||||
TButton *btnMedia;
|
||||
TButton *btnMediana;
|
||||
TButton *btnModa;
|
||||
TLabel *lblTituloEstatisticas;
|
||||
TPanel *pnlPassaAlta;
|
||||
TLabel *lblTituloPassaAlta;
|
||||
TButton *btnSobel;
|
||||
TButton *Button1;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvEqualizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvMediaOnClick(TObject *Sender);
|
||||
void __fastcall EvMedianaOnClick(TObject *Sender);
|
||||
void __fastcall EvModaOnClick(TObject *Sender);
|
||||
void __fastcall EvSobelOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmAlgoritmos(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,81 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmAlgoritmosH
|
||||
#define UFrmAlgoritmosH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmAlgoritmos : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TPanel *pnlImgOriginal;
|
||||
TImage *imgOriginal;
|
||||
TPanel *pnlImgModificado;
|
||||
TImage *imgAlteracao;
|
||||
TPanel *pnlControles;
|
||||
TButton *btnCarregarImagem;
|
||||
TPanel *pnlSegmentacao;
|
||||
TPanel *pnlInfo;
|
||||
TLabel *lblAltura;
|
||||
TEdit *edtAltura;
|
||||
TEdit *edtLargura;
|
||||
TLabel *lblLargura;
|
||||
TLabel *lblTotalPixels;
|
||||
TEdit *edtTotalPixels;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TLabel *lblPixelsProcessados;
|
||||
TLabel *lblTituloSegmentacao;
|
||||
TLabel *lblLimiar;
|
||||
TEdit *edtLimiar;
|
||||
TButton *btnBinarizacao;
|
||||
TLabel *lblCanais;
|
||||
TEdit *edtCanal;
|
||||
TButton *btnQuantizacao;
|
||||
TButton *btnEqualizacao;
|
||||
TPanel *pnlPassaBaixa;
|
||||
TLabel *lblTituloPassaBaixa;
|
||||
TButton *btnMedia;
|
||||
TButton *btnMediana;
|
||||
TButton *btnModa;
|
||||
TLabel *lblTituloEstatisticas;
|
||||
TPanel *pnlPassaAlta;
|
||||
TLabel *lblTituloPassaAlta;
|
||||
TButton *btnSobel;
|
||||
TButton *Button1;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvEqualizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvMediaOnClick(TObject *Sender);
|
||||
void __fastcall EvMedianaOnClick(TObject *Sender);
|
||||
void __fastcall EvModaOnClick(TObject *Sender);
|
||||
void __fastcall EvSobelOnClick(TObject *Sender);
|
||||
void __fastcall EvRobertsOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmAlgoritmos(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmAlgoritmosH
|
||||
#define UFrmAlgoritmosH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmAlgoritmos : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TPanel *pnlImgOriginal;
|
||||
TImage *imgOriginal;
|
||||
TPanel *pnlImgModificado;
|
||||
TImage *imgAlteracao;
|
||||
TPanel *pnlControles;
|
||||
TButton *btnCarregarImagem;
|
||||
TPanel *pnlSegmentacao;
|
||||
TPanel *pnlInfo;
|
||||
TLabel *lblAltura;
|
||||
TEdit *edtAltura;
|
||||
TEdit *edtLargura;
|
||||
TLabel *lblLargura;
|
||||
TLabel *lblTotalPixels;
|
||||
TEdit *edtTotalPixels;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TLabel *lblPixelsProcessados;
|
||||
TLabel *lblTituloSegmentacao;
|
||||
TLabel *lblLimiar;
|
||||
TEdit *edtLimiar;
|
||||
TButton *btnBinarizacao;
|
||||
TLabel *lblCanais;
|
||||
TEdit *edtCanal;
|
||||
TButton *btnQuantizacao;
|
||||
TButton *btnEqualizacao;
|
||||
TPanel *pnlPassaBaixa;
|
||||
TLabel *lblTituloPassaBaixa;
|
||||
TButton *btnMedia;
|
||||
TButton *btnMediana;
|
||||
TButton *btnModa;
|
||||
TLabel *lblTituloEstatisticas;
|
||||
TPanel *pnlPassaAlta;
|
||||
TLabel *lblTituloPassaAlta;
|
||||
TButton *btnSobel;
|
||||
TButton *btnRoberts;
|
||||
TButton *btnLaplaciano;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvEqualizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvMediaOnClick(TObject *Sender);
|
||||
void __fastcall EvMedianaOnClick(TObject *Sender);
|
||||
void __fastcall EvModaOnClick(TObject *Sender);
|
||||
void __fastcall EvSobelOnClick(TObject *Sender);
|
||||
void __fastcall EvRobertsOnClick(TObject *Sender);
|
||||
void __fastcall EvLaplacianoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmAlgoritmos(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmAlgoritmosH
|
||||
#define UFrmAlgoritmosH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmAlgoritmos : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TPanel *pnlImgOriginal;
|
||||
TImage *imgOriginal;
|
||||
TPanel *pnlImgModificado;
|
||||
TImage *imgAlteracao;
|
||||
TPanel *pnlControles;
|
||||
TButton *btnCarregarImagem;
|
||||
TPanel *pnlSegmentacao;
|
||||
TPanel *pnlInfo;
|
||||
TLabel *lblAltura;
|
||||
TEdit *edtAltura;
|
||||
TEdit *edtLargura;
|
||||
TLabel *lblLargura;
|
||||
TLabel *lblTotalPixels;
|
||||
TEdit *edtTotalPixels;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TLabel *lblPixelsProcessados;
|
||||
TLabel *lblTituloSegmentacao;
|
||||
TLabel *lblLimiar;
|
||||
TEdit *edtLimiar;
|
||||
TButton *btnBinarizacao;
|
||||
TLabel *lblCanais;
|
||||
TEdit *edtCanal;
|
||||
TButton *btnQuantizacao;
|
||||
TButton *btnEqualizacao;
|
||||
TPanel *pnlPassaBaixa;
|
||||
TLabel *lblTituloPassaBaixa;
|
||||
TButton *btnMedia;
|
||||
TButton *btnMediana;
|
||||
TButton *btnModa;
|
||||
TLabel *lblTituloEstatisticas;
|
||||
TPanel *pnlPassaAlta;
|
||||
TLabel *lblTituloPassaAlta;
|
||||
TButton *btnSobel;
|
||||
TButton *btnRoberts;
|
||||
TButton *btnLaplaciano;
|
||||
TButton *btnPrewittOnClick;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvEqualizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvMediaOnClick(TObject *Sender);
|
||||
void __fastcall EvMedianaOnClick(TObject *Sender);
|
||||
void __fastcall EvModaOnClick(TObject *Sender);
|
||||
void __fastcall EvSobelOnClick(TObject *Sender);
|
||||
void __fastcall EvRobertsOnClick(TObject *Sender);
|
||||
void __fastcall EvLaplacianoOnClick(TObject *Sender);
|
||||
void __fastcall EvPrewittOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmAlgoritmos(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmAlgoritmos *FrmAlgoritmos;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmAutor.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmAutor *FrmAutor;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmAutor::TFrmAutor(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAutor::EvFecharFormularioOnClick(TObject *Sender)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmAutor::EvFecharFormularioOnClose(TObject *Sender, TCloseAction &Action)
|
||||
{
|
||||
Action = caFree;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,34 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmAutorH
|
||||
#define UFrmAutorH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.Imaging.jpeg.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmAutor : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TImage *ImgAutor;
|
||||
TLabel *lblNome;
|
||||
TLabel *lblRa;
|
||||
TLabel *lblDisciplina;
|
||||
TLabel *lblCurso;
|
||||
TLabel *lblPeriodo;
|
||||
TLabel *lblTermo;
|
||||
TButton *btnSair;
|
||||
void __fastcall EvFecharFormularioOnClick(TObject *Sender);
|
||||
void __fastcall EvFecharFormularioOnClose(TObject *Sender, TCloseAction &Action);
|
||||
|
||||
private: // User declarations
|
||||
public: // User declarations
|
||||
__fastcall TFrmAutor(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmAutor *FrmAutor;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmCapturaOpenCV::TFrmCapturaOpenCV(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,21 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmCapturaOpenCV::TFrmCapturaOpenCV(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmCapturaOpenCV::EvOnClose(TObject *Sender, TCloseAction &Action)
|
||||
{
|
||||
Action = caFree;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,23 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
#include "opencv2/opencv.hpp"
|
||||
using namespace cv;
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmCapturaOpenCV::TFrmCapturaOpenCV(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmCapturaOpenCV::EvOnClose(TObject *Sender, TCloseAction &Action)
|
||||
{
|
||||
Action = caFree;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,24 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
#include "opencv/cv.h"
|
||||
#include "opencv/highgui.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmCapturaOpenCV::TFrmCapturaOpenCV(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmCapturaOpenCV::EvOnClose(TObject *Sender, TCloseAction &Action)
|
||||
{
|
||||
Action = caFree;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,24 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
#include "cv.h"
|
||||
#include "highgui.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmCapturaOpenCV::TFrmCapturaOpenCV(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmCapturaOpenCV::EvOnClose(TObject *Sender, TCloseAction &Action)
|
||||
{
|
||||
Action = caFree;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,21 @@
|
||||
object FrmCapturaOpenCV: TFrmCapturaOpenCV
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
ClientHeight = 575
|
||||
ClientWidth = 794
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIChild
|
||||
OldCreateOrder = False
|
||||
Position = poMainFormCenter
|
||||
Visible = True
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
object FrmCapturaOpenCV: TFrmCapturaOpenCV
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
ClientHeight = 575
|
||||
ClientWidth = 794
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIChild
|
||||
OldCreateOrder = False
|
||||
Position = poMainFormCenter
|
||||
Visible = True
|
||||
OnClose = EvOnClose
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
object FrmCapturaOpenCV: TFrmCapturaOpenCV
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
ClientHeight = 575
|
||||
ClientWidth = 794
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIChild
|
||||
OldCreateOrder = False
|
||||
Position = poMainFormCenter
|
||||
Visible = True
|
||||
OnClose = EvOnClose
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object pnlVideo: TPanel
|
||||
Left = 145
|
||||
Top = 10
|
||||
Width = 510
|
||||
Height = 510
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmCapturaOpenCVH
|
||||
#define UFrmCapturaOpenCVH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmCapturaOpenCV : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
private: // User declarations
|
||||
public: // User declarations
|
||||
__fastcall TFrmCapturaOpenCV(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmCapturaOpenCVH
|
||||
#define UFrmCapturaOpenCVH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmCapturaOpenCV : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
void __fastcall EvOnClose(TObject *Sender, TCloseAction &Action);
|
||||
private: // User declarations
|
||||
public: // User declarations
|
||||
__fastcall TFrmCapturaOpenCV(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmCapturaOpenCVH
|
||||
#define UFrmCapturaOpenCVH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmCapturaOpenCV : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TPanel *pnlVideo;
|
||||
void __fastcall EvOnClose(TObject *Sender, TCloseAction &Action);
|
||||
private: // User declarations
|
||||
public: // User declarations
|
||||
__fastcall TFrmCapturaOpenCV(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmCapturaOpenCV *FrmCapturaOpenCV;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,433 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,439 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
String saida = "";
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
saida += auxiliar[i] + " - "
|
||||
}
|
||||
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,433 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,502 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,490 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int matrizX[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-2; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-2; j++)
|
||||
{
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,490 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int matrizX[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-2; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-2; j++)
|
||||
{
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
//auxiliar[contador] = pixel;
|
||||
//contador++;
|
||||
}
|
||||
}
|
||||
|
||||
//imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,492 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int matrizX[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-2; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-2; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * int matrizX[c-j+1][l-i+1];
|
||||
//auxiliar[contador] = pixel;
|
||||
//contador++;
|
||||
}
|
||||
}
|
||||
|
||||
//imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,500 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int matrizX[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
|
||||
String texto = "";
|
||||
for(int x=0; x<3; x++)
|
||||
{
|
||||
for(int y=0; y<3; y++)
|
||||
{
|
||||
texto += IntToStr(matrizX[x][y]) + " - ";
|
||||
}
|
||||
}
|
||||
ShowMessage(texto);
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-2; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-2; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
//auxiliar[contador] = pixel;
|
||||
//contador++;
|
||||
}
|
||||
}
|
||||
|
||||
//imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,498 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int matrizX[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
|
||||
String texto = "";
|
||||
for(int x=0; x<3; x++)
|
||||
{
|
||||
for(int y=0; y<3; y++)
|
||||
{
|
||||
texto += IntToStr(matrizX[x][y]) + " - ";
|
||||
}
|
||||
}
|
||||
ShowMessage(texto);
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-2; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-2; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 8;
|
||||
//imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,512 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TFrmPrincipal::TFrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvCarregarImagemOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int aux;
|
||||
if(pdgAbrirImagem->Execute())
|
||||
{
|
||||
FrmPrincipal->Caption = "Carregando a imagem...";
|
||||
caminhoArquivo = pdgAbrirImagem->FileName;
|
||||
imgOriginal->Picture->LoadFromFile(caminhoArquivo);
|
||||
imgAlteracao->Picture->LoadFromFile(caminhoArquivo);
|
||||
|
||||
linha = imgOriginal->Picture->Height;
|
||||
edtAltura->Text = linha;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
edtLargura->Text = coluna;
|
||||
aux = linha * coluna;
|
||||
edtTotalPixels->Text = aux;
|
||||
edtPixelsProcessados->Text="";
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvBinarizacaoClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
int pixel;
|
||||
TColor cor;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
if (edtLimiar->Text != "")
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a binarização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
if(pixel < StrToInt(edtLimiar->Text))
|
||||
{
|
||||
pixel = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixel = 255;
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Preencha o valor do limiar!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaOriginal()
|
||||
{
|
||||
Series1->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgOriginal ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem original...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgOriginal->Picture->Height;
|
||||
auxColuna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgOriginal->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfOriginal -> LeftAxis -> Maximum = maior;
|
||||
grfOriginal -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series1-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::gerarHistogramaAlterado()
|
||||
{
|
||||
Series2->Clear();
|
||||
int auxiliar[256];
|
||||
int auxLinha;
|
||||
int auxColuna;
|
||||
int auxPixel;
|
||||
TColor auxCor;
|
||||
int maior = 0;
|
||||
if (imgAlteracao ->Picture->Height != 0)
|
||||
{
|
||||
FrmPrincipal->Caption = "Gerando histograma da imagem alterada...";
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
|
||||
auxLinha = imgAlteracao ->Picture->Height;
|
||||
auxColuna = imgAlteracao ->Picture->Width;
|
||||
|
||||
for(int i=0; i<auxLinha; i++)
|
||||
{
|
||||
for(int j=0; j<auxColuna; j++)
|
||||
{
|
||||
auxCor=imgAlteracao->Canvas->Pixels[j][i];
|
||||
auxPixel = GetRValue(auxCor);
|
||||
auxiliar[auxPixel]++;
|
||||
if(maior < auxiliar[auxPixel])
|
||||
{
|
||||
maior = auxiliar[auxPixel];
|
||||
}
|
||||
}
|
||||
}
|
||||
grfModificado -> LeftAxis -> Maximum = maior;
|
||||
grfModificado -> BottomAxis -> Maximum = 255;
|
||||
for(int x=0; x<256; x++)
|
||||
{
|
||||
Series2-> AddXY(x, auxiliar[x], "", TColor(x,x,x));
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvQuantizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
if (edtCanal->Text != "")
|
||||
{
|
||||
if ((StrToInt(edtCanal->Text) > 0) && (StrToInt(edtCanal->Text) <128))
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a quantização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
int divisao = 256/(StrToInt(edtCanal->Text));
|
||||
int auxiliarValor;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliarValor = pixel%(divisao);
|
||||
auxiliarValor = divisao-auxiliarValor-1;
|
||||
pixel+=auxiliarValor;
|
||||
auxiliar[pixel]++;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(pixel, pixel, pixel);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe uma quantidade de canais entre 1 e 127!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Informe a quantidade de canais!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvEqualizacaoOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int auxiliar[256];
|
||||
int novo[256];
|
||||
int ideal;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
auxiliar[i] = 0;
|
||||
novo[i] = 0;
|
||||
}
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a equalização...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
ideal = (linha * coluna)/256;
|
||||
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0; j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[pixel]++;
|
||||
}
|
||||
}
|
||||
int auxiliarValor = 0;
|
||||
for(int i=0; i<256; i++)
|
||||
{
|
||||
auxiliarValor += auxiliar[i];
|
||||
if(((auxiliarValor/ideal)-1)>0)
|
||||
{
|
||||
novo[i] = (auxiliarValor/ideal)-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
novo[i] = 0;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<linha; i++)
|
||||
{
|
||||
for(int j=0;j<coluna; j++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[j][i];
|
||||
pixel = GetRValue(cor);
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(novo[pixel], novo[pixel], novo[pixel]);
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
qtd += auxiliar[i];
|
||||
}
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMediaVizinhanca(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int soma;
|
||||
int media;
|
||||
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a média de vizinhança...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
soma = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
soma += pixel;
|
||||
}
|
||||
}
|
||||
media = soma/9;
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(media, media, media);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvMedianaOnClick(TObject *Sender)
|
||||
{
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int contador;
|
||||
int auxiliar[9];
|
||||
int aux;
|
||||
|
||||
for(int x=0; x<9; x++)
|
||||
{
|
||||
auxiliar[x] = 0;
|
||||
}
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando a mediana...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-1; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-1; j++)
|
||||
{
|
||||
contador = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
auxiliar[contador] = pixel;
|
||||
contador++;
|
||||
}
|
||||
}
|
||||
for(int x=0; x<8; x++)
|
||||
{
|
||||
for(int y=x+1; y<9; y++)
|
||||
{
|
||||
if(auxiliar[y] < auxiliar[x])
|
||||
{
|
||||
aux = auxiliar[x];
|
||||
auxiliar[x] = auxiliar[y];
|
||||
auxiliar[y] = aux;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TFrmPrincipal::EvSobelOnClick(TObject *Sender)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int linha;
|
||||
int coluna;
|
||||
TColor cor;
|
||||
int pixel;
|
||||
int qtd=0;
|
||||
int aux;
|
||||
int gradX;
|
||||
int gradY;
|
||||
int matrizX[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
|
||||
int matrizY[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};
|
||||
String texto = "";
|
||||
for(int x=0; x<3; x++)
|
||||
{
|
||||
for(int y=0; y<3; y++)
|
||||
{
|
||||
texto += IntToStr(matrizX[x][y]) + " - ";
|
||||
}
|
||||
}
|
||||
ShowMessage(texto);
|
||||
if (imgOriginal ->Picture-> Height != 0)
|
||||
{
|
||||
imgAlteracao->Picture = NULL;
|
||||
imgAlteracao->Picture->Bitmap->SetSize(imgOriginal ->Picture->Width,imgOriginal ->Picture->Height);
|
||||
FrmPrincipal->Caption = "Aplicando o filtro de Sobel...";
|
||||
linha = imgOriginal->Picture->Height;
|
||||
coluna = imgOriginal->Picture->Width;
|
||||
|
||||
for(int i=1; i<linha-2; i++)
|
||||
{
|
||||
for(int j=1; j<coluna-2; j++)
|
||||
{
|
||||
gradX = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradX += pixel * matrizX[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradX /= 8;
|
||||
|
||||
gradY = 0;
|
||||
for(int l=i-1; l<=i+1;l++)
|
||||
{
|
||||
for(int c=j-1; c<=j+1; c++)
|
||||
{
|
||||
cor=imgOriginal->Canvas->Pixels[c][l];
|
||||
pixel = GetRValue(cor);
|
||||
gradY += pixel * matrizY[l-i+1][c-j+1];
|
||||
}
|
||||
}
|
||||
gradY /= 8;
|
||||
//imgAlteracao->Canvas->Pixels[j][i] = RGB(auxiliar[4], auxiliar[4], auxiliar[4]);
|
||||
qtd++;
|
||||
}
|
||||
}
|
||||
gerarHistogramaOriginal();
|
||||
gerarHistogramaAlterado();
|
||||
edtPixelsProcessados->Text = qtd;
|
||||
FrmPrincipal->Caption = "Processamento de imagem digital.";
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessage("Carregue a imagem antes!");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
TFrmAlgoritmos *janela = new TFrmAlgoritmos();
|
||||
janela->Visible = true;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,22 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,23 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
ShowMessage("foi");
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,22 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,23 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,23 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,28 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::_EvCapturaOpenCVOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmCapturaOpenCV(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,28 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
#include "UFrmCapturaOpenCV.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvCapturaOpenCVOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmCapturaOpenCV(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,22 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -0,0 +1,28 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "UFrmPrincipal.h"
|
||||
#include "UFrmAlgoritmos.h"
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma resource "*.dfm"
|
||||
TfrmPrincipal *frmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TfrmPrincipal::TfrmPrincipal(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvAlgoritmosOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAlgoritmos(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TfrmPrincipal::EvSobreOnClick(TObject *Sender)
|
||||
{
|
||||
new TFrmAutor(this);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
OnClose = EvOnClose
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniCapturaOpenCV: TMenuItem
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
end
|
||||
end
|
||||
object mnuSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniCapturaOpenCV: TMenuItem
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
end
|
||||
end
|
||||
object mnuSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniCapturaOpenCV: TMenuItem
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
end
|
||||
end
|
||||
object mnuSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniCapturaOpenCV: TMenuItem
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
OnClick = _EvCapturaOpenCVOnClick
|
||||
end
|
||||
end
|
||||
object mnuSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,37 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniCapturaOpenCV: TMenuItem
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
OnClick = EvCapturaOpenCVOnClick
|
||||
end
|
||||
end
|
||||
object mnuSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniCapturaOpenCV: TMenuItem
|
||||
Caption = 'Captura de v'#237'deo com OpenCV'
|
||||
end
|
||||
end
|
||||
object mnuSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
OnClick = EvSobreOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
object frmPrincipal: TfrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Software de processamento de imagens'
|
||||
ClientHeight = 573
|
||||
ClientWidth = 792
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
FormStyle = fsMDIForm
|
||||
Menu = mnuPrincipal
|
||||
OldCreateOrder = False
|
||||
WindowState = wsMaximized
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object mnuPrincipal: TMainMenu
|
||||
Left = 552
|
||||
Top = 304
|
||||
object mnuProcessamento: TMenuItem
|
||||
Caption = 'Processamento de imagens'
|
||||
object mniAlgoritmos: TMenuItem
|
||||
Caption = 'Algoritmos de processamento de imagem...'
|
||||
OnClick = EvAlgoritmosOnClick
|
||||
end
|
||||
object mniSobre: TMenuItem
|
||||
Caption = 'Sobre...'
|
||||
OnClick = EvSobreOnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,229 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 89
|
||||
Caption = 'tblOpcoes'
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 89
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 178
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,231 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 89
|
||||
Caption = 'tblOpcoes'
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 89
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 178
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,232 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 89
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 89
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 178
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,233 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 89
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 89
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 178
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,240 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 89
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 89
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 178
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TToolButton
|
||||
Left = 267
|
||||
Top = 0
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
ImageIndex = 3
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,240 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 89
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 89
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 178
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TToolButton
|
||||
Left = 267
|
||||
Top = 0
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
ImageIndex = 3
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,247 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 103
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 103
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 206
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TToolButton
|
||||
Left = 309
|
||||
Top = 0
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
ImageIndex = 3
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
object btnMediaVizinhanca: TToolButton
|
||||
Left = 412
|
||||
Top = 0
|
||||
Caption = 'M'#233'dia da vizinhan'#231'a'
|
||||
ImageIndex = 4
|
||||
OnClick = EvMediaVizinhanca
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,254 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 103
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 103
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 206
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TToolButton
|
||||
Left = 309
|
||||
Top = 0
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
ImageIndex = 3
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
object btnMediaVizinhanca: TToolButton
|
||||
Left = 412
|
||||
Top = 0
|
||||
Caption = 'M'#233'dia da vizinhan'#231'a'
|
||||
ImageIndex = 4
|
||||
OnClick = EvMediaVizinhanca
|
||||
end
|
||||
object btnMediana: TToolButton
|
||||
Left = 515
|
||||
Top = 0
|
||||
Caption = 'Mediana'
|
||||
ImageIndex = 5
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,254 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 103
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 103
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 206
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TToolButton
|
||||
Left = 309
|
||||
Top = 0
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
ImageIndex = 3
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
object btnMediaVizinhanca: TToolButton
|
||||
Left = 412
|
||||
Top = 0
|
||||
Caption = 'M'#233'dia da vizinhan'#231'a'
|
||||
ImageIndex = 4
|
||||
OnClick = EvMediaVizinhanca
|
||||
end
|
||||
object btnMediana: TToolButton
|
||||
Left = 515
|
||||
Top = 0
|
||||
Caption = 'Mediana'
|
||||
ImageIndex = 5
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,261 @@
|
||||
object FrmPrincipal: TFrmPrincipal
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
Caption = 'Processamento de imagem digital.'
|
||||
ClientHeight = 662
|
||||
ClientWidth = 1008
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
Position = poDesktopCenter
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Top = 25
|
||||
Width = 1006
|
||||
Height = 72
|
||||
TabOrder = 0
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Top = 42
|
||||
Width = 27
|
||||
Height = 13
|
||||
Caption = 'Limiar'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 199
|
||||
Top = 12
|
||||
Width = 69
|
||||
Height = 13
|
||||
Caption = 'Total de pixels'
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 104
|
||||
Top = 12
|
||||
Width = 37
|
||||
Height = 13
|
||||
Caption = 'Largura'
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 8
|
||||
Top = 12
|
||||
Width = 29
|
||||
Height = 13
|
||||
Caption = 'Altura'
|
||||
end
|
||||
object Label5: TLabel
|
||||
Left = 104
|
||||
Top = 42
|
||||
Width = 32
|
||||
Height = 13
|
||||
Caption = 'Canais'
|
||||
end
|
||||
object Label6: TLabel
|
||||
Left = 343
|
||||
Top = 12
|
||||
Width = 90
|
||||
Height = 13
|
||||
Caption = 'Pixels processados'
|
||||
end
|
||||
object edtLimiar: TEdit
|
||||
Left = 41
|
||||
Top = 36
|
||||
Width = 57
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtTotalPixels: TEdit
|
||||
Left = 274
|
||||
Top = 7
|
||||
Width = 63
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 1
|
||||
end
|
||||
object edtLargura: TEdit
|
||||
Left = 147
|
||||
Top = 9
|
||||
Width = 46
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 2
|
||||
end
|
||||
object edtAltura: TEdit
|
||||
Left = 43
|
||||
Top = 9
|
||||
Width = 55
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object edtCanal: TEdit
|
||||
Left = 147
|
||||
Top = 36
|
||||
Width = 46
|
||||
Height = 21
|
||||
NumbersOnly = True
|
||||
TabOrder = 4
|
||||
end
|
||||
object edtPixelsProcessados: TEdit
|
||||
Left = 439
|
||||
Top = 7
|
||||
Width = 58
|
||||
Height = 21
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
object grfOriginal: TChart
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 489
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 1
|
||||
ColorPaletteIndex = 13
|
||||
object Series1: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object grfModificado: TChart
|
||||
Left = 512
|
||||
Top = 432
|
||||
Width = 488
|
||||
Height = 222
|
||||
Legend.Visible = False
|
||||
Title.Text.Strings = (
|
||||
'Histograma')
|
||||
BottomAxis.Title.Caption = 'Tonalidade'
|
||||
LeftAxis.Title.Caption = 'Quantidade'
|
||||
TabOrder = 2
|
||||
ColorPaletteIndex = 13
|
||||
object Series2: TBarSeries
|
||||
Marks.Arrow.Visible = True
|
||||
Marks.Callout.Brush.Color = clBlack
|
||||
Marks.Callout.Arrow.Visible = True
|
||||
Marks.Visible = False
|
||||
Title = 'seriaModificado'
|
||||
XValues.Name = 'X'
|
||||
XValues.Order = loAscending
|
||||
YValues.Name = 'Bar'
|
||||
YValues.Order = loNone
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 93
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 3
|
||||
object imgOriginal: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 597
|
||||
Top = 110
|
||||
Width = 310
|
||||
Height = 310
|
||||
TabOrder = 4
|
||||
object imgAlteracao: TImage
|
||||
Left = 5
|
||||
Top = 5
|
||||
Width = 300
|
||||
Height = 300
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 300
|
||||
Stretch = True
|
||||
end
|
||||
end
|
||||
object tblOpcoes: TToolBar
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 1008
|
||||
Height = 29
|
||||
BorderWidth = 1
|
||||
ButtonHeight = 21
|
||||
ButtonWidth = 103
|
||||
Caption = 'tblOpcoes'
|
||||
DrawingStyle = dsGradient
|
||||
EdgeBorders = [ebLeft, ebTop, ebRight, ebBottom]
|
||||
ShowCaptions = True
|
||||
TabOrder = 5
|
||||
Wrapable = False
|
||||
object btnCarregarImagem: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Carregar imagem'
|
||||
ImageIndex = 0
|
||||
OnClick = EvCarregarImagemOnClick
|
||||
end
|
||||
object btnBinarizacao: TToolButton
|
||||
Left = 103
|
||||
Top = 0
|
||||
Caption = 'Binarizacao'
|
||||
ImageIndex = 1
|
||||
OnClick = EvBinarizacaoClick
|
||||
end
|
||||
object btnQuantizacao: TToolButton
|
||||
Left = 206
|
||||
Top = 0
|
||||
Caption = 'Quantiza'#231#227'o'
|
||||
ImageIndex = 2
|
||||
OnClick = EvQuantizacaoOnClick
|
||||
end
|
||||
object btnEqualizacao: TToolButton
|
||||
Left = 309
|
||||
Top = 0
|
||||
Caption = 'Equaliza'#231#227'o'
|
||||
ImageIndex = 3
|
||||
OnClick = EvEqualizacaoOnClick
|
||||
end
|
||||
object btnMediaVizinhanca: TToolButton
|
||||
Left = 412
|
||||
Top = 0
|
||||
Caption = 'M'#233'dia da vizinhan'#231'a'
|
||||
ImageIndex = 4
|
||||
OnClick = EvMediaVizinhanca
|
||||
end
|
||||
object btnMediana: TToolButton
|
||||
Left = 515
|
||||
Top = 0
|
||||
Caption = 'Mediana'
|
||||
ImageIndex = 5
|
||||
OnClick = EvMedianaOnClick
|
||||
end
|
||||
object ToolButton1: TToolButton
|
||||
Left = 618
|
||||
Top = 0
|
||||
Caption = 'Sobel'
|
||||
ImageIndex = 6
|
||||
OnClick = EvSobelOnClick
|
||||
end
|
||||
end
|
||||
object pdgAbrirImagem: TOpenPictureDialog
|
||||
InitialDir = 'img'
|
||||
Left = 480
|
||||
Top = 160
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,57 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TButton *btnCarregarImagem;
|
||||
TButton *btnBinarizacao;
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TImage *imgOriginal;
|
||||
TImage *imgAlteracao;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TButton *btnQuantizacao;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall btnBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall _EvQuantizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TButton *btnCarregarImagem;
|
||||
TButton *btnBinarizacao;
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TButton *btnQuantizacao;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall btnBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall _EvQuantizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TButton *btnCarregarImagem;
|
||||
TButton *btnBinarizacao;
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TButton *btnQuantizacao;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
TBarSeries *Series3;
|
||||
TBarSeries *Series4;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall btnBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall _EvQuantizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TButton *btnCarregarImagem;
|
||||
TButton *btnBinarizacao;
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TButton *btnQuantizacao;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall btnBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall _EvQuantizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TButton *btnCarregarImagem;
|
||||
TButton *btnBinarizacao;
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TButton *btnQuantizacao;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall btnBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall _EvQuantizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
TToolBar *tblOpcoes;
|
||||
TToolButton *btnCarregarImagem;
|
||||
TToolButton *btnBinarizacao;
|
||||
TToolButton *btnQuantizacao;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall _EvQuantizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
TToolBar *tblOpcoes;
|
||||
TToolButton *btnCarregarImagem;
|
||||
TToolButton *btnBinarizacao;
|
||||
TToolButton *btnQuantizacao;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
TToolBar *tblOpcoes;
|
||||
TToolButton *btnCarregarImagem;
|
||||
TToolButton *btnBinarizacao;
|
||||
TToolButton *btnQuantizacao;
|
||||
TToolButton *btnEqualizacao;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvEqualizacaoOnClick(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef UFrmPrincipalH
|
||||
#define UFrmPrincipalH
|
||||
//---------------------------------------------------------------------------
|
||||
#include <System.Classes.hpp>
|
||||
#include <Vcl.Controls.hpp>
|
||||
#include <Vcl.StdCtrls.hpp>
|
||||
#include <Vcl.Forms.hpp>
|
||||
#include <Vcl.Dialogs.hpp>
|
||||
#include <Vcl.ExtCtrls.hpp>
|
||||
#include <Vcl.ExtDlgs.hpp>
|
||||
#include <VCLTee.Chart.hpp>
|
||||
#include <VCLTee.Series.hpp>
|
||||
#include <VCLTee.TeEngine.hpp>
|
||||
#include <VCLTee.TeeProcs.hpp>
|
||||
#include <Vcl.ComCtrls.hpp>
|
||||
#include <Vcl.ToolWin.hpp>
|
||||
//---------------------------------------------------------------------------
|
||||
class TFrmPrincipal : public TForm
|
||||
{
|
||||
__published: // IDE-managed Components
|
||||
TOpenPictureDialog *pdgAbrirImagem;
|
||||
TPanel *Panel1;
|
||||
TLabel *Label1;
|
||||
TEdit *edtLimiar;
|
||||
TLabel *Label2;
|
||||
TEdit *edtTotalPixels;
|
||||
TLabel *Label3;
|
||||
TEdit *edtLargura;
|
||||
TLabel *Label4;
|
||||
TEdit *edtAltura;
|
||||
TChart *grfOriginal;
|
||||
TChart *grfModificado;
|
||||
TBarSeries *Series2;
|
||||
TBarSeries *Series1;
|
||||
TLabel *Label5;
|
||||
TEdit *edtCanal;
|
||||
TLabel *Label6;
|
||||
TEdit *edtPixelsProcessados;
|
||||
TPanel *Panel2;
|
||||
TImage *imgOriginal;
|
||||
TPanel *Panel3;
|
||||
TImage *imgAlteracao;
|
||||
TToolBar *tblOpcoes;
|
||||
TToolButton *btnCarregarImagem;
|
||||
TToolButton *btnBinarizacao;
|
||||
TToolButton *btnQuantizacao;
|
||||
TToolButton *btnEqualizacao;
|
||||
TToolButton *btnMediaVizinhanca;
|
||||
void __fastcall EvCarregarImagemOnClick(TObject *Sender);
|
||||
void __fastcall EvBinarizacaoClick(TObject *Sender);
|
||||
void __fastcall gerarHistogramaOriginal();
|
||||
void __fastcall gerarHistogramaAlterado();
|
||||
void __fastcall EvQuantizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvEqualizacaoOnClick(TObject *Sender);
|
||||
void __fastcall EvMediaVizinhanca(TObject *Sender);
|
||||
private: // User declarations
|
||||
String caminhoArquivo;
|
||||
public: // User declarations
|
||||
__fastcall TFrmPrincipal(TComponent* Owner);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
extern PACKAGE TFrmPrincipal *FrmPrincipal;
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
Loaded 100 of 158 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user