void CResizableImage::HorizontalFilter(unsigned int dst_width, unsigned int dst_height)
{

	if (dst_width == myWidth)
	{
		// No scaling required, just copy
		memcpy (myResizedImage, myRGBArray, sizeof(RGBQUAD) * myWidth * myHeight);
	}

	myWeightsTable = new CWeightsTable(myFilter, dst_width, myWidth);

	for (UINT u = 0; u < dst_height; u++)
	{
		// scale each row
		ScaleRow (dst_width, dst_width, u);	// Scale each row 
	}

	delete myWeightsTable;
}
示例#2
0
// Reduces all elements in a column except the diagonal element
// Returns 0 on success, 1 if the column cannot be reduced
int Matrix::ReduceColumn(int column, Matrix &inverse)
{
	// loop variable for working down column
	int row, pivot = column;

	// find the first non-zero element in the column
	// that is not above the diagonal
	for (row = pivot; row < 4; row++)
		if (fabs(Element(row, pivot)) > ERROR_TOLERANCE)
			break;

	// if we didn't find one, return an error code
	if (row == 4) return 1;

	// if we did, but it wasn't on the diagonal, swap with the pivot row
	// this makes sure we never get divide by zero errors
	if (row != pivot)
	{
		SwapRows(pivot, row);
		inverse.SwapRows(pivot, row);
	}

	// now scale the pivot row so the pivot element is one
	float scaleFactor = 1.0 / Element(pivot, pivot);
	ScaleRow(pivot, scaleFactor);
	inverse.ScaleRow(pivot, scaleFactor);

	// for each row
	for (row = 0; row < 4; row++)
	{
		// skip the row we're pivoting on
		if (row == column) continue;
		scaleFactor = -Element(row, pivot);
		AddRows(row, scaleFactor, pivot);
		inverse.AddRows(row, scaleFactor, pivot);
	}

	// and we're done
	return 0;
}