You may think of monochrome as black and white, and that is partly true. But a black and white image can also have a tint applied, and still fall into the monochrome category. The original color image and a monochrome image tinted cyan can be seen below.
This program runs on iPad only. The pixel count of smaller devices makes it impossible to process an image of sufficient size.
Code: Select all
/* Color to Monochrome By rbytes, March 2018 This app will allow you to select an image from a Smart Basic folder or the Camera Roll and convert it to monochrome. With the rshift(red), gshift(green) and bshift(blue) values set to 1, you will get a perfect black and white image. If you modify the shift values by a small percentage (eg. .9 or 1.1, you can produce a tinted monochrome. How do you know that the proper shade of grey is produced for each colored area of the image? The eyes are most sensitive to green light. The brightness you perceive is contributed 59% from frequencies in the green range, 30% in the red range and 11% in the blue range. Check the conversion algorithm to see how I applied these percentages. */ 'comment or uncomment the next 2 lines to determine if loading an image file im$="head" ' set the string to an image file in Smart Basic, minus extender ext$=".jpg" ' set the string to the image file's extender ' comment or uncomment the next 3 lines to determine if importing from the Camera Roll 'im$="temp" 'ext$=".jpg" 'ALBUM IMPORT im$&ext$ s=.38 ' scale to draw the image (experiment to get the size you want) rshift=.8!gshift=1!bshift=1 SET TOOLBAR OFF GET IMAGE im$&ext$ SIZE W,H GET SCREEN SIZE sw,sh GRAPHICS BUTTON "stop" TEXT "STOP" AT sw-80,20 GRAPHICS CLEAR DRAW IMAGE im$&ext$ AT 0,0 SCALE s FOR y=0 TO H*2*s FOR x=0 TO W*2*s GET PIXEL x,y COLOR R,G,B,A ' the next line is the algorithm for luminance (brightness) r1=R*.3+G*.59+B*.11!g1=r1*gshift!b1=r1*bshift!r1=r1*rshift!a1=A DRAW PIXEL x,y COLOR r1,g1,b1,a1 NEXT x IF BUTTON_PRESSED("stop") THEN END NEXT y GRAPHICS SAVE 0,0,W*s,H*s TO im$&"-mono"&ext$ ALBUM EXPORT im$&"-mono"&ext$