Want gray scale image of a matrix in matlab

In summary, the conversation discusses creating a gray-scale image of a 2000x2000 matrix using the mat2gray and imshow commands. However, it is mentioned that the imshow command can only handle up to a 500x500 matrix, resulting in a warning message. The speaker is looking for a way to plot all 2000x2000 matrix entries in gray-scale and suggests reducing the size of the array or using gnuplot to write the matrix to a file. The other speaker suggests using the imwrite function to generate a png file from the data.
  • #1
beman
16
0
I am creating a gray-scale image of a 2000*2000 matrix using mat2gray and imshow command.But highest number of matrix entries that imshow can implement is 500*500 approximately.After that it shows------

"Warning: Image is too big to fit on screen; displaying at 8%
> In imuitools\private\initSize at 72
In imshow at 259 "

I know what is going on here but I want my all 2000*2000 matrix entries to be plotted in gray-scale. Is there any possible way?Please suggest some easy way because I am new in matlab.
 
Physics news on Phys.org
  • #2
You could reduce your 2000x2000 to a 500x500 array by taking every fourth element or better yet average the elements in a 4x4 square to be the single element in the 500x500 image.
 
  • #3
No I want full resolution.Because for 500*500 case boundaries in image is not sharp enough for experimental purpose.
 
  • #4
If you can write the matrix to a file you can use gnuplot.
Not sure which functions you should/could use but it's possible. (I used it once for a simulation of the Ising model)
 

FAQ: Want gray scale image of a matrix in matlab

What is a gray scale image in Matlab?

A gray scale image in Matlab is an image that uses varying shades of gray to represent different levels of brightness or intensity. It is a commonly used image format in scientific research and data analysis.

How can I convert a matrix to a gray scale image in Matlab?

To convert a matrix to a gray scale image in Matlab, you can use the mat2gray function. This function maps the values in your matrix to a range of 0 to 1, which corresponds to the shades of gray in the image.

Can I customize the gray scale range in Matlab?

Yes, you can customize the gray scale range in Matlab by specifying the limits parameter in the mat2gray function. This allows you to map your matrix values to a specific range of gray shades, instead of the default 0 to 1 range.

How do I display a gray scale image in Matlab?

To display a gray scale image in Matlab, you can use the imshow function. This function takes in a grayscale image as input and displays it in a figure window.

Can I save a gray scale image in Matlab?

Yes, you can save a gray scale image in Matlab by using the imwrite function. This function allows you to specify the file format and file name for your image, and it will be saved to your current working directory.

Similar threads

Replies
1
Views
2K
Replies
4
Views
3K
Replies
2
Views
3K
Replies
32
Views
3K
Replies
2
Views
1K
Replies
7
Views
3K
Replies
4
Views
2K
Replies
1
Views
2K
Replies
1
Views
10K
Back
Top