11-05 20:19
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

[Image Processing] Embossing 본문

Scientific Computing/Image Processing

[Image Processing] Embossing

cinema4dr12 2014. 6. 6. 14:57

MATLAB CODE: "Embossing.m"

function Embossing %% read an image img = imread('./res/test_01.jpg'); img = rgb2gray(img); subplot(2,1,1); imshow(img); mask = [-1 0 0 ; 0 0 0 ; 0 0 1]; [rSize, cSize] = size(mask); [nrow, ncol] = size(img); img = cast(img, 'double'); newImg = zeros(nrow,ncol); % Corners subMask = mask(2:3,2:3); i = 1; j = 1; subMat = img(i:i+1,j:j+1); newImg(i,j) = sum(sum(subMask.*subMat)) + 128; subMask = mask(1:2,1:2); i = nrow; j = ncol; subMat = img(i-1:i,j-1:j); newImg(i,j) = sum(sum(subMask.*subMat)) + 128; % Edges subMask = mask(2:3,1:3); i = 1; for(j = 2:ncol-1) subMat = img(i:i+1,j-1:j+1); newImg(i,j) = sum(sum(subMask.*subMat)) + 128; end subMask = mask(1:2,1:3); i = nrow; for(j = 2:ncol-1) subMat = img(i-1:i,j-1:j+1); newImg(i,j) = sum(sum(subMask.*subMat)) + 128; end subMask = mask(1:3,2:3); j = 1; for(i = 2:nrow-1) subMat = img(i-1:i+1,j:j+1); newImg(i,j) = sum(sum(subMask.*subMat)) + 128; end subMask = mask(1:3,1:2); j = ncol; for(i = 2:nrow-1) subMat = img(i-1:i+1,j-1:j); newImg(i,j) = sum(sum(subMask.*subMat)) + 128; end % Inner for(i = 0.5*(rSize+1) : nrow - 0.5*(rSize+1)) for(j = 0.5*(cSize+1) : ncol - 0.5*(cSize+1)) subMat = img(i-1:i+1,j-1:j+1); newImg(i,j) = sum(sum(subMat.*mask)) + 128; end end subplot(2,1,2); newImg = cast(newImg, 'uint8'); imshow(newImg); end


테스트용 이미지 (test_01.jpg)

 


결과 (위: 원본 이미지, 아래: Embossing 처리된 이미지)


Comments