I have a set of randomly spaced 2D data and would like to convert it into an image. I want to create an image whose intensity is 255 on the random points and zero elsewhere. I interpolate the data into a fine and evenly spaced grid (meshgrid format) using the following code but I failed. After I interpolate, the image is not an exact match or even close to the representation of random points. If you compare subplot(2,1,1) and subplot(2,1,2) in the following code, it can be seen that all the space between the random points gets 255. Is there a better way to convert the data to an image?
I would be grateful for any help.
% Range of random number for x and y. L = 8; H = 6;
% The number of random numbers. n = 100;
% Randomly spaced data. x = rand( n, 1 )*L; y = rand( n, 1 )*H;
% Intensity of the data points are 'White'. intensity = ones(size(x))*255; subplot( 2,1,1 ) plot( x, y, '.' )
% Interpolate the data into a rectangular evenly spaced grid. [ X, Y ] = meshgrid( 0:0.01:L, 0:0.01:H ); F = TriScatteredInterp( x, y, intensity ); intensityInterp = F( X, Y ); subplot(2,1,2) imshow( intensityInterp )
No products are associated with this question.
You might also try adding lots of additional scattered points with intensity zero. That will give the interpolation code information about what intensity lies in between the high intensity points.
In any case, whatever interpolator you choose, you will be accepting the interpolator's idea of how the intensity transitions from high to zero. So, to inform that choice, you have to have some idea of what you want that transition to be.