

To plot this data in Matlab, you must interpolate the data on a uniform grid, as shown below. If you want to convert that into an indexed image (with a separate colormap) see the rgb2ind function.

In the following example, notice that the Gaussian profile is not sampled uniformly in the Y direction.

This is an important detail when plotting data obtained from a non-uniform mesh. This is not true of the image command in the Lumerical script environment. The standard image command in MATLAB assumes that matrix data is uniformly sampled, even when you provide the x,y position vectors. % transpose matrix, plot data, add color barĢD image plot with non-uniform, rectilinear data MATLAB commands to generate equivalent plot To get the same figure orientation in MATLAB as in your Lumerical plots, you must apply an unconjugated transpose operation and adjust the axes, as shown below.ĢD image plot with uniform, rectilinear data Follow 15 views (last 30 days) Show older comments Abhishek Tiwari on 0 Answered: Amit Dhakite on Accepted Answer: Amit Dhakite I have an image in PNG format with dimensions (N x M) and a specific point (x, y) within the image, I need determine the corresponding 3D world coordinate of this point using MATLAB. MATLAB uses a different convention for plotting 2D matrix data than Lumerical. So as you see the image looks 3D but the data is actually 2D.This page shows how to create 2D image plots of data from Lumerical's software using MATLAB. Or we can use any other colormap of our choice.Ĭolormap(jet(200)) %// The size can be different than the original colormap

For instance, we can use the original colormap (stored in map) in order to get the following: image(X) If we wish to display this 2D data as a colorful we need to provide a suitable colormap. So a 2D variable, even though the original image ( a) was 3D (rgb). for ex, if we get 3D image of a rock and we need only the cylinder rock and ignore the author things First, how to write a code that convert first, how to write a code that convert 2D images to 3-D image Second, after we have a 3-D image. Let's read and use the rgb2ind function to store the image data in variable X and its associated colormap in variable map. Write me a code that convert 2D images to 3D image using MATLAB,then take the important part from the image. So if the colormap is a 256x3 array, for example, the image will be made of indices ranging from 0 to 255.įor example, let's consider the peppers.png demo image that ships with Matlab. In this case the colormap will be a Nx3 array where each row corresponds to an index present (or not) in the image data. If I understood right you can store the image data as a 2D array and use a colormap to assign it colors, displaying it as a "colorful" image.
