stretch float[320,240] to float[640,480] and maintain data integrity

I have a radiometric image (320px by 240px) with temperature data behind each pixel

I have extracted the temperature data and put into float[320, 240];
Then I can reference by X Y and get the temperature data


This all works fine, I over lay the temperature data over the image, and when the user hovers it shows the temperature data for that pixel

however I need to now increase the size of the image for display purposes and on hover show the temperatures, the image bit is easy, I just set in CSS

However, the original data (X Y pixels) also needs to be stretched so when the user hovers it shows the correct temperatures
The issue is the original data half the size, so would somehow need to duplicate diagonally

here is the code in question which gets the data into the float array.
I now need to return a float array of 640,480, with the correct pixel temperature data
Any idea how i would stretch the float array and maintain the correct pixel data considering the original is 320x240 and the output needs to be 640x480 ?

_tempData = new float[320, 240];

            using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(tempContents)))
            {
                BinaryReader br = new BinaryReader(ms);
                for (int x = 0; x < 320; x++)
                {
                    for (int y = 0; y < 240; y++)
                    {

                        //write temp value for pixel
                        float pixelTemperature = br.ReadSingle();
                         _tempData[x, y] = pixelTemperature;
                      }
                 }
             }

return _tempData;

Open in new window

websssCEOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
If you are doubling each point in the display then halving the display x, y gives you the matrix index
sarabandeCommented:
to add to Andy's solution:

increasing the image to 640x480 quadruples the number of pixels. so 4 neighbored pixels are associated with same temperature value. for example the quadrupel of pixels { { 12, 4 }, { 13, 4}, {12, 5}, { 13, 5} } is associated to the pair { 6, 2 } in the temperature matrix.

you wouldn't need a new increased float array but use your current 2D array and compute the x,y indices from pixel coordinates (px, py) in the hover function by

x = px/2;
y = py/2;

Open in new window


so you are halving the coordinates as told by Andy.

note, the indices must be int type such that integer division applies for odd coordinates.

Sara

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndyAinscowFreelance programmer / ConsultantCommented:
If you didn't understand my comment then feel free to ask for further clarification.  The comment by sarabande is just explaining why my comment appears to be what you asked for.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET MVC

From novice to tech pro — start learning today.