Skip to main content

Ulichney Digital Halftoning- Ordered Dithering (Dispersed Dot, Clustered Dot ) MATLAB, Python Code

To understand digital halftoning and ordered dithering please check this page

http://imageprocessing-sankarsrin.blogspot.tw/2016/12/digital-half-toning-ordered-dithering.html


Python Code:

https://github.com/SankarSrin/Digital-Halftoning



MATLAB Code:

%%%%%%%Function to generate Ulichney Halftone Patterns%%%%%%%%%%

%%   Author:
%%   Mr. Sankarasrinivasan
%%   Research Fellow, Multimedia Signal Processing Lab, NTUST, Taiwan
%%   Advisor: Prof. Jing Ming Guo
%%   Dated: Apr, 2018

%met=1 (clustered dot 4x4); met=2 (clustered dot 8x8) met=3 dispersed dot

function [HOD]=Ulichney(im,met)
im=im2double(im);
[s1 s2]=size(im);


if(met==1)
 
od=[12 05 06 13;
    04 00 01 07;
    11 03 02 08;
    15 10 09 14;]/15;
 
bs=4;

elseif(met==2)
 
 od=[0.567 0.635 0.608 0.514 0.424 0.365 0.392 0.486
    0.847 0.878 0.910 0.698 0.153 0.122 0.090 0.302
    0.820 0.969 0.941 0.667 0.180 0.031 0.059 0.333
    0.725 0.788 0.757 0.545 0.275 0.212 0.243 0.455
    0.424 0.365 0.392 0.486 0.567 0.635 0.608 0.514
    0.153 0.122 0.090 0.302 0.847 0.878 0.910 0.698
    0.180 0.031 0.059 0.333 0.820 0.969 0.941 0.667
    0.275 0.212 0.243 0.455 0.725 0.788 0.757 0.545];
bs=8;

elseif(met==3)
    od=[131 187 8 78 50 18 134 89 155 102 29 95 184 73;
        22 86 113 171 142 105 34 166 9 60 151 128 40 110;
        168 137 45 28 64 188 82 54 124 189 80 13 156 56;
        7 61 186 121 154 6 108 177 24 100 38 176 93 123;
        83 148 96 17 88 133 44 145 69 161 139 72 30 181;
        115 27 163 47 178 65 164 14 120 48 5 127 153 52;
        190 58 126 81 116 21 106 77 173 92 191 63 99 12;
        76 144 4 185 37 149 192 39 135 23 117 31 170 132;
        35 172 103 66 129 79 3 97 57 159 70 141 53 94;
        114 20 49 158 19 146 169 122 183 11 104 180 2 165;
        152 87 182 118 91 42 67 25 84 147 43 85 125 68;
        16 136 71 10 193 112 160 138 51 111 162 26 194 46;
        174 107 41 143 33 74 1 101 195 15 75 140 109 90;
        32 62 157 98 167 119 179 59 36 130 175 55 0 150;]/196;
    bs=14;
    im=imresize(im, [504 504]);
    [s1 s2]=size(im);
end


mask=repmat(od,s1/bs,s2/bs);
H=zeros(s1,s2);
HOD=im>mask;

end






Comments

  1. Anyone here interested in Wavelets?

    Check in my dissertation below!

    Follow link:

    http://repositorio.unicamp.br/jspui/bitstream/REPOSIP/338849/1/Bonello_DanielKatz_M.pdf

    ReplyDelete

Post a Comment

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

Digital Half-toning Error Diffusion Method (Floyd-Steinberg) - MATLAB Code

Introduction to Digital Half toning is provided in the below link http://imageprocessing-sankarsrin.blogspot.tw/2016/12/digital-half-toning-ordered-dithering.html The halftones are generally obtained by thresholding each image pixel with a certain value (ex. 128). In error diffusion, the error is computed between the actual and obtained output and it is distributed to the neighborhood pixels. Floyd-Stein berg, Jarvis, Stucki kernels are widely adopted  to distribute the error. The Error Diffusion half toning is as follows 1) image(x,y) > 128  Apply thresholding (assume  the image pixel value is 157,  in that case, 255 will be assigned to output). ( as the half toning corresponds to two values 0 and 255) 2) Compute the error between actual and obtained output    E=   255-157= 98 3) In case of floyd steinberg the value 98 is distributed along the neighborhood pixels 4) This steps are performed in sequence and serpentine scan yields superior halftone output. The ma