Programación Sobol
Originalmente, Sobel tenía un pequeño algoritmo para encontrar el umbral, pero generalmente no es necesario, por lo que utilicé la sección áurea multiplicada por 255.
El código convolucional de Sobel es el siguiente:
¿No es válido? CSobelDlg::CreateSobolImage(void)
{
¿Electricidad estática? constante? int? tamañoDeSobelMask? =?9;
¿Electricidad estática? int? sobelMaskHor[tamañoDeSobelMask]? =?
{
-1,?-2,?-1,?
? 0,0,0,
? 1,2,1
};
¿Electricidad estática? int? ¿SobelMask[tamañoDeSobelMask]? =?
{
1,?0,?-1,
2,?0,?-2,
1 ,?0,?1
};
int? número de bytes? =?m_bmpInfo.bmWidthBytes? *?m _ Información BMP .Altura BM;
¿Sin firmar? carbonizarse*? pbuf1? =?Nuevo? ¿No firmado? char[numOfBytes];
¿Sin firmar? carbonizarse*? pbuf2? =?Nuevo? ¿No firmado? char[numOfBytes];
m_bmpOrg.
GetBitmapBits(numOfBytes, pbuf 1);
¿Sin firmar? ¿Ciel? color promedio? =?0;
for(int?stroke?=?0;?stroke?& lt?m _ Información BMP . Altura BM;?++?line)
{
for(int?col?=?0;?col?<?m_BMP info.BM width;?++column)
{
averageColor? =?(?pbuf1[fila?*?m_bmpInfo.bmWidthBytes?+?Cole?*?m_bmpInfo.bmBitsPixel?/?8?+?0]?+
pbuf1[fila?*?m_bmpInfo. bmWidthBytes ? *?m_bmpInfo.bmBitsPixel?/?8?+?2]?)?/?3;
pbuf1[fila? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?0]?=?Color promedio;
}
}
¿Sin firmar? ¿Ciel? ts? =?0,?TV? =?0,?tmp? =?0,?dst? =?0,?idx? =?0;
for(int?stroke?=?1;?stroke?<?m_bmpInfo.bmHeight?-?1;?++?line)
{< / p>
for(int?col?=?1;?col?<?m_bmpInfo.bmWidth?-?1;?++columna)
{
idx? =?ts? =?TV? =?0;
for(int?r?=?carrera?-?1;?r?& lt=?carrera?+?1;?++r)
{
for(int?c?=?kohl?-?1;?c?& lt=?kohl?+?1;?++c)
{ p>
tmp? =?pbuf1[r? *?m_bmpInfo.bmWidthBytes? +?c? *?m_bmpInfo.bmBitsPixel? /?8];
ts? +=?(sobelMaskHor[idx]?*?tmp?);
TV? +=?(SobelMaskVer[idx]?*?tmp?);
++ idx;
}
}
dst ? =?(Unsigned?char)sqrt(?(float)(ts?*?ts?+?TV?*?TV)?);
If (dst?& gt?(Unsigned? char) (0.6180339887?*?255.0)?)?{
pbu F2[fila? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?0]?=?0;
pbu F2[plataforma? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?1]?=?255;
pbu F2[plataforma? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?2]?=?0;
pbu F2[plataforma? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.
bmBitsPixel? /?8?+?3]?=?255;
}
¿Y si? {
pbu F2[¿pelotón? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?0]?=?0;
pbu F2[plataforma? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?1]?=?0;
pbu F2[plataforma? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?2]?=?255;
pbu F2[plataforma? *?m_bmpInfo.bmWidthBytes? +?Cole? *?m_bmpInfo.bmBitsPixel? /?8?+?3]?=?255;
}
}
}
m_bmpSobol. CreateBitmap(m_bmpInfo.bmWidth,?m_bmpInfo.bmHeight,?1,?32,?pbu F2);
¿Eliminar? []pbuf 1;
¿Eliminar? []pbu F2;
}
Les daré otra representación de este programa.