Matrix padding with zeros

3 visualizaciones (últimos 30 días)
Darek Myszk
Darek Myszk el 29 de Abr. de 2020
Respondida: Geoff Hayes el 29 de Abr. de 2020
Hello. I have a problem with my program. I make encryption by image. I based on 16-bit blocks. When I load picture (e.g. 16x16 / 128x128 / 256x256) and make my transformation on this everythink is ok. The problem occurs when the image has different dimensions (e.g. 50x50). In this case I have a size matrix: 50x50x3 (rgb). I have to extend each sub matrix to 64 (modulo 16, rounding up to a full multiple of 16) by add '255' so that finally the combination of three '255' gives white. Any ideas?

Respuestas (1)

Geoff Hayes
Geoff Hayes el 29 de Abr. de 2020
Darek - perhaps create the 64x64x3 matrix with all elements set to 255 and then replace a subset of that matrix with the 50x50x3.
myImage = uint8(randi(255,50,50,3));
myPaddedImage = uint8(255*ones(64,64,3));
myPaddedImage(1:50,1:50,:) = myImage;

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by