3 Replies Latest reply on Jun 19, 2010 2:17 AM by T Beddard

    Setting input and output image sizes

    T Beddard Level 1

      I'm working on a new filter where I want to take a source image say 1024x512 pixels large, do some transformations and then want to render a resulting image at 512x512.


      Two questions:

      1) Is it possible to automatically set a float2 size parameter based on the input image size? e.g:


      input image4 src;

      parameter float2 size


        inputSize: float2(1024, 512);

        defaultValue: float2(1024, 512);

        displayName: "Input image size";

        componentName: "Width|Height";

        inputSizeName: "src";



      I would like the 'size' float2 to be automatically populated with the dimensions of input image 'src'. Note, if I don't specify the defaultValue parameter then the size always reverts to 0, 0.



      2) I have another parameter to set the outputSize and am currently doing it like this:


      parameter int2 outputSize


        minValue: int2(200, 200);

        maxValue: int2(4096, 4096);

        defaultValue: int2(1024, 512);

        stepInterval: 1;

        displayName: "Image size";

        componentName: "Width|Height";



      region generated()


        return region(float4(0, 0, outputSize.x, outputSize.y));


      output pixel4 dst;


      However the actual rendered area is never less than the input image size, i.e. if I set the output image width to be 512 pixels it will always still render the same width as the input image 1024.


      I still haven't got my head round how regions should be used. How should I approach this?





      BTW, the filter I'm working on it for creating 'Little Planet' images (sterographic projection) from equirectangular panoramas. I'll be releasing it soon