select particular 8 *8 blocks then change the pixel values of this blocks to 0
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I divided an image to 8*8 blocks, then I want to select particular blocks and change the pixel values of this blocks to 0, the index of blocks to select are for example v=[1,23,25,87,96].
Can anyone help me please
0 Kommentare
Antworten (1)
Parth Dethaliya
am 22 Dez. 2020
Bearbeitet: Parth Dethaliya
am 24 Dez. 2020
Assuming you have numbered the blocks row-wise.
You can simply crop any indexed block likw this:
Im is the main image
Block_Index = 23;
Dividing_Factor = size(Im,2)/8;
R1 = 1 + 8*(floor(Block_Index-1./Dividing_Factor));
R2 = R1 +7;
C1 = 1 + 8*(mod(Block_Index-1,Dividing_Factor));
C2 = C1 +7;
Im(R1:R2,C1:C2) = 0; % Or any value you want to give
I hope this is the solution you were finding.
7 Kommentare
Parth Dethaliya
am 11 Jan. 2021
Initially you were divind in 8*8 blocks so the code was written accordingly, If you need it for 16*16 blocks then definately you will have to make some changes, same code won't work.
Changes for dividing te image in NxN blocks:
Dividing_Factor = size(Im,2)/N;
R1 = 1 + (N-1)*(floor((Block_Index-1)./Dividing_Factor));
R2 = R1 +(N-1);
C1 = 1 + N*(mod(Block_Index-1,Dividing_Factor));
C2 = C1 +(N-1);
Siehe auch
Kategorien
Mehr zu Computer Vision with Simulink finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!