Topic: [Feature Idea] Image based correlator for Convolution/Corelation

I think that and Correlation and Convolution  (flipping the correlator image both vertically and horrizontally, and then performing cross correlation) should be put into IA, using an image (instead of manually entered table) for input. It would be a "Combine Images" feature and not intended to replace the already existing kernel filter (with a manually entered table) that is an already present feature in IA.

In the Combine Images panel, there should be options for doing these. Correlation is where you take a base image and a correlator image and at each pixel of the base image, you multiply the surrounding pixels by their corresponding pixels and then take these multiplication results and sum them together. You do this for every pixel in the base image. Cross Correlation is where the base image and correlator image are different. Auto Correlation could also be performed by simply selecting the same image for both the base and correlator images.

Convolution is the opposite, in the sense that you flip the correlator image horizontally and vertically before performing correlation.

So both Correlation and Convolution should be added to the "Combine Images" dialog box.

As usual, a bias number should be available, but in this case it makes sense to include 2 biases, one for the base image and one for the correlator image. A check box option to go with both of these should be to normalize the output (otherwise the output easily get above 255 or below 0).

2

Re: [Feature Idea] Image based correlator for Convolution/Corelation

If you convert both images to floating point maps and save one of them to a file, you can actually do the correlation with the User defined filter feature. It is fairly slow for big images though.

Michael Vinther

> software developer <

3 (edited by Ben321 2012-02-02 11:38:02)

Re: [Feature Idea] Image based correlator for Convolution/Corelation

admin wrote:

If you convert both images to floating point maps and save one of them to a file, you can actually do the correlation with the User defined filter feature. It is fairly slow for big images though.

Thanks for the info.


However that seems like a bit of a tedious process because:
What about the convolution? You said that correlation is done with the userdefiened filter.

I did try what you suggested for the correlation, but it gives me the error "filter matrix is too big", even when I'm ONLY USING something like an 12x24 size image.  You said it would "go slow" if it was too big. You never said it would "generate an error".

Also being able to do it without first saving FP maps (or any image for that matter) to a file would be nice.

4

Re: [Feature Idea] Image based correlator for Convolution/Corelation

As you said yourself, convolution is just a question of flipping the image and it is probably not something that is used that often, so it is not on the todo list..
I just tried filtering a 256x256 image with a 256x256 filter and it worked fine. Are you sure you converted both the image and the filter to floating point maps?
By the way, after the filtering you should probably open the Complex representation dialog and set it to Auto scale.

Michael Vinther

> software developer <

Re: [Feature Idea] Image based correlator for Convolution/Corelation

How do I set the scale factor for the image map I'm using as the user-defined filter? When I convert an image to an image map, I have a real-valued image map with values from 0 to 255. Problem is this doesn't have the correct scale factor, so when I perform convolution/correlation with it I end up with HUGE values in the output. If there was a way to set the scale factor so that it would normalize the image I'm using for convolution/correlation (the total value of all the pixels in the image map would sum to the value 1), that would fix this problem, but I don't know how to set the scale factor, or even perform mathematical operations on it (like image map pixel values divide by 1000000).

6

Re: [Feature Idea] Image based correlator for Convolution/Corelation

Does it matter that the result gets huge values? Can't you just enable Auto scale in the Complex representation dialog?

Anyway, you can scale the values manually by using Operations | Transformations | Update with expression and enter an expression like p/255.
In that case you probably want to divide by the sum of all pixel values. To get the sum you can use the Script feature. Try using this script:

using System;
using MeeSoft.ImageProcessing;

public class ScriptOp : MeeSoft.ImageProcessing.Operations.ScriptOperation.Base
{
    float _sum;
    
    public override void Apply()
    {
        base.Apply();
        WriteLn("Pixel sum: " + _sum);
    }

    protected override float GetPixel(int x, int y, int p, BitmapPlane source)
    {
        lock(SrcBitmap)
          _sum += source[x,y];
        return source[x,y];
    }
}
Michael Vinther

> software developer <