1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| function [ bloc_traite] = traitement(bloc) % notre fonction à* appliquer sur chaque bloc
%DIVISION_FONCT Summary of this function goes here
% Detailed explanation goes here
blk=input('entrer N');
Im=imread('Fm.jpg') ; % Notre image de départ
C=size(Im);
blocSize = [C(1) C(2)];
for i = 1:blk:C(1)
for j = 1:blk:C(2)
bloc = Im(i:i+(blk-1) , j:j+(blk-1));
fun=@BTC;
bloc_traite = blockproc(bloc,[blk blk],fun); % je veux diviser chaque bloc c en bloc NxN, pour faire le traitement seulement sur le bloc NxN.
bloc_traite = traitement(bloc); % Traitement du bloc
resultat(i:i+blocSize(1)-1 , j:j+blocSize(2)-1) = bloc_traite; % Stockage du bloc résultat
function[]=BTC()
Im=[i : i+(blk-1) j : j+(blk-1)];
y=Im;
m=mean(mean(y));
sig=std2(y);
s=y>m;
q=sum(sum(s));
if (q ~= blk^2) && (q ~= 0)
a=m-sig*sqrt(q/((blk^2)-q));
b=m+sig*sqrt(((blk^2)-q)/q);
end
if ( y > m )
Im=b;
else
Im=a;
end
end
end
end
end |
Partager