vtkImageDataPtr convertToTestColorImage(vtkImageDataPtr image)
{
	int numberOfTableValues = 256;
	vtkLookupTablePtr lut = createLookupTable(numberOfTableValues);
	vtkImageDataPtr retval = applyLUTToImage(image, lut);
	return retval;
}
/*
 * Find k-mismatches not bounded by k.
 * @param text A character array containing the text
 * @param pattern A character array containing the pattern
 * @param n the length of the text
 * @param m the length of the pattern
 * @param k The threshold, k. If k < 0 or >= m hamming distance at all
 * alignments will be found
 * @param results. An unsigned array to store the hamming distance in. Must be
 * of size n-m+1. If NULL, results are printed to stdout.
 * @param numMatches an unsigned pointer to a location to store the number
 * of k-mismatches found. Note that if k < 0 or >= m this is just n-m.
 */
void sp_km_unbounded_kmismatch(char *text, char *pattern, int n, int m,int k,
		int *numMatches,struct SP_KM_MATCHING_POSITIONS *listOfMatches, unsigned int flags){
	int i;
	if( k < 0){
		k = m+1;
	}
	*numMatches = 0;

	struct charAndPosition *sortedPattern = (struct charAndPosition *)malloc(sizeof(struct charAndPosition) * m);
	struct position *positionLookup = (struct position *)malloc(sizeof(struct position)*NUM_CHARS);

	//Set all characters to be non-existant in the pattern
	for(i=0;i<NUM_CHARS;i++){
		positionLookup[i].charType = NOT_IN_PATTERN;
	}
	int frequentThreshold = (int)sqrt((double)m*log2((double)m));
	
	printf("Frequent threshold: %d\n", frequentThreshold);
	//printf("Frequent threshold: %d\n",frequentThreshold);
//	frequentThreshold = 2;
	createLookupTable(pattern,m,sortedPattern,positionLookup,frequentThreshold,NULL);
	findMismatchesWithoutFiltering(text,pattern,n,m,k,numMatches,listOfMatches,flags,sortedPattern,positionLookup);
	free(sortedPattern);
	free(positionLookup);
}
int ColourGradient::createLookupTable (const AffineTransform& transform, HeapBlock <PixelARGB>& lookupTable) const
{
    JUCE_COLOURGRADIENT_CHECK_COORDS_INITIALISED // Trying to use this object without setting its coordinates?
    jassert (colours.size() >= 2);

    const int numEntries = jlimit (1, jmax (1, (colours.size() - 1) << 8),
                                   3 * (int) point1.transformedBy (transform)
                                                .getDistanceFrom (point2.transformedBy (transform)));
    lookupTable.malloc ((size_t) numEntries);
    createLookupTable (lookupTable, numEntries);
    return numEntries;
}