Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert a three-channel color RGB image to a one-channel grayscale image or matrix
ResourceFunction["OneChannelGrayscale"][img] converts color image img to a single-channel grayscale image. | |
ResourceFunction["OneChannelGrayscale"][img,"ImageData"] returns the image data matrix of the grayscale image. |
| "Luminosity" (default) | uses the luminosity algorithm, which is a weighted average |
| "Mean" | uses the mean algorithm on the 3 channel RGB colors pixels |
Convert a color image to a grayscale:
| In[1]:= | ![]() |
| Out[1]= | ![]() |
Look at the image information:
| In[2]:= |
| Out[2]= | ![]() |
Convert the same image to grayscale using the mean algorithm:
| In[3]:= | ![]() |
| Out[3]= | ![]() |
2D numerical matrix can be seen with ArrayPlot:
| In[4]:= | ![]() |
| Out[4]= | ![]() |
Convert an AI image synthesis to grayscale:
| In[5]:= | ![]() |
| Out[5]= | ![]() |
Image exams, such as X-rays or mammograms, are in gray scale. Still, the images are usually 3-channel RGB, it is better to convert to one channel grayscale for faster computation and clean up data:
| In[6]:= |
| Out[6]= | ![]() |
Find a general test image and convert to grayscale:
| In[7]:= | ![]() |
| Out[8]= | ![]() |
Compare information for the images:
| In[9]:= |
| Out[9]= | ![]() |
Convert an image to grayscale and then colorize it using ArrayPlot:
| In[10]:= | ![]() |
| Out[10]= | ![]() |
Convert three faces to grayscale:
| In[11]:= |
| In[12]:= |
| Out[12]= | ![]() |
Convert the same faces using the unweighted mean:
| In[13]:= |
| Out[13]= | ![]() |
Compare to the resource function "FaustGrayscaleConvert":
| In[14]:= |
| Out[14]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License