Skip to main content

Digital Multitoning - Dispersed Dot MATLAB Code

function MT=DDMT()

%DDMT- Dispersed  Dot Multitoning (MT)
%Code by: Sankarasrinivasan S,
%Multimedia Signal Processing Lab
%NTUST, Taipei

%Input Image
im=imread('cameraman.tif');

%Reference
%K. Chandu M. Stanich C. W. Wu B. Trager "Direct multi-bit search (DMS) screen algorithm" Proc. 19th IEEE Int. Conf. Image Process. pp. 817-820 Sep./Oct. 2012.
%Dispersed Dot Multitone Screen generated using the referred paper
%3-tone image require two screens

DA=[ 141 189 208 102 251 174 217 165 198 252 204 129 180 150 217 249 174 245 69 223 145 191 134 245 107 137 188 224 244 209 160 199 219 97 231 123 197 235 207 83 213 231 173 158 142 177 239 147 188 163 215 139 241 101 171 227 152 133 238 197 251 193 136 228 89 252 152 203 82 221 116 249 190 211 167 222 99 214 85 207 156 196 227 177 247 98 205 162 94 243 113 185 165 234 182 242 236 185 135 212 148 194 233 182 218 195 226 206 247 125 202 140 210 159 240 172 225 107 142 239 139 175 155 96 194 173 221 176 130 217 191 80 251 200 220 170 202 252 210 233 110 230 105 249 170 245 101 209 126 151 115 245 158 179 137 74 244 128 190 205 87 199 74 230 184 235 213 135 229 192 223 199 119 216 162 224 234 121 219 111 241 165 90 173 206 81 237 85 251 70 239 125 149 252 143 193 204 147 222 249 95 215 187 126 212 197 184 172 202 178 228 162 247 177 196 63 182 243 110 227 153 88 222 242 137 214 129 212 72 225 160 232 209 168 201 103 247 171 206 157 233 44 238 182 201 127 240 185 124 220 47 235 191 229 93 194];
DA1=[30 80 118 52 76 33 59 12 26 148 114 24 54 111 124 65 104 133 17 169 6 113 91 156 70 39 61 100 74 20 45 13 50 25 180 86 47 66 15 44 179 21 87 9 37 91 72 108 127 60 38 10 158 23 143 119 7 104 50 122 64 117 5 34 8 120 77 110 55 186 35 53 75 32 81 13 29 153 56 168 48 63 21 31 131 5 73 128 17 147 58 131 43 78 18 103 15 112 95 68 45 166 27 40 109 49 3 69 143 27 115 71 93 34 4 122 19 59 87 65 11 89 121 23 53 83 2 40 75 54 144 51 92 161 2 124 77 30 61 164 37 151 66 146 11 116 25 179 9 43 57 26 99 47 102 8 181 14 45 30 60 155 42 138 64 82 189 71 16 112 21 147 55 91 135 100 187 23 168 13 35 105 14 38 130 42 157 33 167 20 48 7 39 84 50 67 96 29 120 154 53 144 65 6 98 142 109 77 106 4 114 22 132 49 79 5 118 11 36 176 51 27 59 18 63 95 57 89 2 109 19 138 31 76 140 68 15 132 117 35 166 11 154 28 150 41 99 85 56 94 3 161 79 41 2 82];
DA=vec2mat(DA,16); DA1=vec2mat(DA1,16); DA(:,:,1)=DA; DA(:,:,2)=DA1;

T=2; %No of screen size is less than 3
bs=16;
[s1 s2]=size(im);

MT=ones(bs,bs);
NT=ones(bs,bs);
for i=1:bs:s1
    for j=1:bs:s2 
        bl=im(i:i+(bs-1),j:j+(bs-1));                 
        for nT=1:1:T   
        MT=(bl>=DA(:,:,nT));   
        M(:,:,nT)=MT;   
        end
   

       for x=1:1:bs
           for y=1:1:bs                   
              if(M(x,y,1)==1 )
                  blc(x,y)=1;
              elseif(M(x,y,2)==1)
                  blc(x,y)=0.5;     
                           
              else
                  blc(x,y)=0;
              end
           
           end
       end
     
 
 Y(i:i+(bs-1),j:j+(bs-1))=blc;
       end 
end
 
imshow(Y);
end



Comments

Popular posts from this blog

Image RGB to CMYK : Image Conversion - MATLAB Code (RGB to CMYK, CMYK to RGB)

MATAB use makecform and applycform functions to perform this color model conversion  Ref: makecform:  https://www.mathworks.com/help/images/ref/makecform.html Ref: applycform:  https://www.mathworks.com/help/images/ref/applycform.html RGB to CMYK: I_rgb = imread('lena_color.jpg'); %Read the color image  C = makecform('srgb2cmyk');     %srgb (standard rgb) to cmyk  I_CMYK= applycform(I_rgb,C); TO SAVE IN CMYK Format imwrite(I_CMYK, 'test.tiff'); USE IMFINFO to confirm the conversion imfinfo('test.tiff') the command gives the output ... Width: 512 Height: 512 BitDepth: 32 ColorType: 'CMYK' ... CMYK to RGB: I_CMYK = imread('lena_color.jpg'); %Read the color image  C = makecform('cmyk2srgb');     %srgb (standard rgb) to cmyk  I_rgb= applycform(I_CMYK, C);

Digital Half Toning - Ordered Dithering - MATLAB Code Bayer/ Ulichney

Digital Half-toning is a technique to convert the gray scale / color image (in the range 0-255) to binary images (in the range 0-1)  that is useful for printing (especially black and white printers). Though at first glance dots are clearly visible, as Human Vision System is a low pass filter, when dots are printed closely and viewed from the specific distance it can be perceived as a continuous tone image (i.e. gray scale). In general, half toning techniques is widely used in newspapers, journals and magazines printing.  Halftoning algorithms aims for better #Image Quality #Low Complexity #Optimal ink usage Coming to the topic, Ordered dithering is one of the standard technique to produce halftone image from continuous (gray scale) images. Let us assume, the first block containing 'B' is an image matrix and the  'H' is the threshold matrix. And the process is simply a element wise (pixel wise) comparison; if element of B > H (g...

Direct Binary Search Halftoning (DBS) - MATLAB Code (Efficient Direct Binary Search, Halftoning)

Direct binary approach is a heuristic optimization method and is proven to be very powerful to  obtain optimized binary patterns. The approach achieves the least minimum square error between the perceived halftone and original image, though swap and toggle operation. The swap operation consists of switching the current pixel with eight of its neighborhood pixels. Toggle operation is about switching the values between 0 to 1 or vice versa (as shown in Fig. below)      With each iteration, the perceived error starts to reduce and in finally a superior halftone quality is achieved. The method is computationally very expensive and difficult to implement in hardware. The code for Efficient DBS is provided in the link: (MATLAB Code) https://github.com/SankarSrin/EDBS-Halftoning