aresta
O aresta é uma bancada de processamento de imagens em C++, escrita do zero, para estudo e experimentação de algoritmos. Reúne o processamento clássico do livro do Gonzalez e os algoritmos de segmentação por grafo da linha da Transformada Imagem-Floresta (IFT e OIFT), que são o tema da pesquisa de mestrado do autor no IME-USP. aresta is an image processing workbench written from scratch in C++ for studying and experimenting with algorithms. It brings together the classic processing from Gonzalez's textbook and the graph-based segmentation algorithms of the Image Foresting Transform line (IFT and OIFT), which are the topic of the author's Master's research at IME-USP.
Ver no GitHubView on GitHub
A cadeiaThe chain
A unidade de trabalho é a cadeia: uma lista ordenada de operações em que a saída de cada estágio fica guardada, inspecionável e cronometrada. Mudar um parâmetro reavalia a cadeia inteira e mostra o efeito em qualquer ponto dela, não só no fim. The unit of work is the chain: an ordered list of operations where each stage's output is kept, inspectable and timed. Changing a parameter re-evaluates the whole chain and shows the effect at any point in it, not just at the end.
A cadeia é tipada. Cada estágio produz cor (RGBA float32 em espaço linear), escalar (Map<float>) ou rótulo (Map<int32_t>), e ligações inválidas são recusadas antes de rodar. As ligações são por id, então apagar um estágio do meio não reescreve as referências dos seguintes.
The chain is typed. Each stage produces color (linear-space RGBA float32), scalar (Map<float>) or label (Map<int32_t>), and invalid connections are rejected before running. Connections are by id, so deleting a stage in the middle doesn't rewrite the references of the ones after it.
OperaçõesOperations
| GrupoGroup | OperaçõesOperations |
|---|---|
| Tom e histogramaTone and histogram | exposição, gama, curva por fórmula, equalização, CLAHE, casamento de histograma, Otsu e multi-Otsuexposure, gamma, formula curves, equalization, CLAHE, histogram matching, Otsu and multi-Otsu |
| VizinhançaNeighborhood | convolução com editor de kernel, médias, filtros de ordem, filtros adaptativosconvolution with a kernel editor, means, order-statistic filters, adaptive filters |
| FrequênciaFrequency | FFT 2D, filtros ideal/Butterworth/gaussiano, degradação, filtro inverso, Wiener e mínimos quadrados restritos2D FFT, ideal/Butterworth/Gaussian filters, degradation, inverse filter, Wiener and constrained least squares |
| CorColor | RGB, HSV, HSI, Lab, YCbCr, CMY, gradiente vetorial, pseudo-corvector gradient, pseudo-color |
| Binário e morfologiaBinary and morphology | limiar local (Sauvola), Canny, LoG, Hough para retas e círculos, morfologia, afinamento, reconstrução geodésica, componentes, transformada de distância exatalocal thresholding (Sauvola), Canny, LoG, Hough for lines and circles, morphology, thinning, geodesic reconstruction, components, exact distance transform |
| SegmentaçãoSegmentation | mínimos regionais com h, watershed por marcadores (IFT com custo fmax)regional minima with h, marker-based watershed (IFT with fmax cost) |
| DescriçãoDescription | descritores de região e momentos de Hu, descritores de Fourier, textura por co-ocorrência (Haralick)region descriptors and Hu moments, Fourier descriptors, co-occurrence texture (Haralick) |
| Entre estágiosBetween stages | aritmética, overlay, ruído com semente fixa, métricas (RMSE, MAE, PSNR, SNR, SSIM)arithmetic, overlay, seeded noise, metrics (RMSE, MAE, PSNR, SNR, SSIM) |
ValidaçãoValidation
- O watershed bate pixel a pixel com o
segmentation.watersheddo scikit-image, com e sem linha divisória e com e sem máscara.The watershed matches scikit-image'ssegmentation.watershedpixel by pixel, with and without watershed lines and with and without a mask. - Em 1024×1024 com 56 mil marcadores, o watershed roda em cerca de meio segundo, porque cada pixel entra na fila uma única vez.At 1024×1024 with 56 thousand markers, the watershed runs in about half a second, because each pixel enters the queue only once.
- Área, centroide, eixos, orientação e momentos de Hu batem com o
regionprops; os momentos de Hu em dez dígitos.Area, centroid, axes, orientation and Hu moments matchregionprops; Hu moments to ten digits. - A fronteira sai igual à do
findContoursdo OpenCV, ponto a ponto, e os coeficientes de Fourier batem com onumpy.fft.Boundaries match OpenCV'sfindContourspoint by point, and Fourier coefficients matchnumpy.fft. - O SSIM confere com o scikit-image em cinco casas, e as medidas de Haralick com o
graycopropsaté 1e-16.SSIM agrees with scikit-image to five decimal places, and Haralick measures withgraycopropsto 1e-16.
Projetos e exportaçãoProjects and export
Um projeto .aresta é texto legível, uma linha por campo, para dar para comparar duas versões num diff. Qualquer estágio pode ser exportado como aparece (PNG, JPEG) ou com os valores crus (PFM, PGM de 16 bits, CSV, NPY), e a cadeia inteira pode ser exportada como uma figura com legendas, pronta para artigo.
An .aresta project is readable text, one line per field, so two versions can be compared in a diff. Any stage can be exported as displayed (PNG, JPEG) or with raw values (PFM, 16-bit PGM, CSV, NPY), and the whole chain can be exported as a captioned figure ready for a paper.
BuildBuild
$ sudo apt install build-essential cmake ninja-build libsdl2-dev libgl-dev $ ./build.sh Release $ ./aresta imagem.png
Próximos passosNext steps
- Pincel de sementes, IFT e OIFT sobre a imagem.Seed brush, IFT and OIFT on the image.
- Bancada de grafos: montar, desenhar, rodar algoritmos e exportar.Graph workbench: build, draw, run algorithms and export.
- Modo benchmark: rodar sobre um dataset, cronometrar e medir.Benchmark mode: run over a dataset, time and measure.
- Wavelets e casamento por correlação.Wavelets and correlation matching.