For Ubuntu Linux, I came up with this process.
Obtain the source image preferably as an uncompressed format. Examples include *.bmp, *.png, etc.
Install ImageMagick on Ubuntu OS. Usually it is installed by default on the newer versions of Ubuntu.
Use GIMP to scale the images as required DPI. Prefer cubic, bi-cubic or better scaling algorithms to minimize loss of data during the scaling.
Now execute these statements.
Install OpenCV, Dosbox and Wine using
sudo apt-get install libopencv-* dosbox wine
and save the following program as rgb2gray.cc
//#include <cv.h>
//#include <highgui.h>
#include <opencv2/opencv.hpp>
#include <cstdio>
#include <cstdlib>
using namespace cv;
int main( int argc, char** argv )
{
if( argc != 3 )
{
printf( " No image data \n " );
printf( "Usage: ./rgb2gray <colorimage>.<ext> <grayimage>.<ext> \n" );
printf( "Usage: ./rgb2gray colorimage.png grayimage.png \n" );
exit(0);
}
char* imageName = argv[1];
Mat image;
image = imread( imageName, 1 );
Mat gray_image;
cvtColor( image, gray_image, CV_BGR2GRAY );
imwrite( argv[2], gray_image );
namedWindow( imageName, CV_WINDOW_AUTOSIZE );
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
imshow( imageName, image );
imshow( "Gray image", gray_image );
waitKey(0);
return 0;
}
Type the following on terminal to compile the code:
g++ -g rgb2gray.cc -o rgb2gray `pkg-config opencv --libs --cflags`
Now, execute the following commands.
./rgb2gray colorimage.png grayimage.png
convert -compress none grayimage.png logo.tif
Note: Make sure the tif image name is not longer than 8 characters, otherwise you may face problems in further steps
Google internet to find ztoolssetup107.exe. I found one here http://www.hjollum.com/jari/zzbug/ztools/download.php
Install Ztools using wine by right clicking on exe file and selecting open with wine.
Navigate to the following path where Ztools are installed
cd ~/.wine/drive_c/ztools
and copy the logo.tif you created previously there cp <path to tif image>/logo.tif .
Now for the final steps
Open Dosbox by executing dosbox .
and inside the Dosbox terminal type ZIMAGLIT.EXE logo.tif logo.grf
and thats it!!!
Note: If you do not see ZIMAGLIT.EXE you may have to obtain it via Google. I am hoping the ZImage link above contains the same.
Troubleshooting:
Q. Why is my GRF completely all 0s?
A. Because the source monochrome images should be binary (after rgb2gray conversion). i.e. every pixel on the image should be either black or while. Avoid shades of Gray or convert Gray areas in the image to jet black (pixel values = 255). Then retry the process.
Q. ZIMAGLIT.EXE is unable to convert my TIF image to GRF?
A. Because the tif image name (not including tif extension) should be less than or equal to 8 characters preferably all alphabets. Rename the same if it does not match this condition. Then retry the process.