I have a dicom image,I of size :
size(I)
ans =
716 1000 3
From this I took first 64 bits,like I(1:16),I(17:32),I(33:48),I(49:64) and did the encryption operation. So before sending it I would like to get back the remaining bits and thus get back the image?
I hope the question is clear.Here I took Ist rows upto 64. This is stored in suppose a variable A.How to get the remaining bits, so that if store the variable in B. So that after decryption of A,I can concatenate with B and get back the final image.
Can somebody help me out to get this?

5 commentaires

Darsana P M
Darsana P M le 14 Avr 2018
can somebody help me out??
John D'Errico
John D'Errico le 14 Avr 2018
Nobody has answered you probably because your question is very unclear as to exactly what you did.
I have to perform encryption using AES-GCM on dicom image. The dicom image I is of size:
size(I)
ans =
716 1000 3
For the algorithm, i have taken the first 64 bits, like this:
A1=I(1:16)
A2=I(17:32)
A3=I(33:48)
A4=I(49:64)
Thus after performing encryption using AES-GCM, I get back the 64 bits.
These bits I need to concatenate with the remaining bits in image I, which is of size:
size(I)
ans =
716 1000 3
What must be done to concatenate the remaining bits, and get an image?
Walter Roberson
Walter Roberson le 14 Avr 2018
Those are not the first 64 bits. The first 64 bits are probably I(1:4) or I(1:8)
However AES-GCM of a dicom image needs the first 64 bits of the dicom file itself, not of the image stored in the file.
Darsana P M
Darsana P M le 15 Avr 2018
Modifié(e) : Walter Roberson le 15 Avr 2018
Sir, I have separated the dicom header data and pixel data using matlab functions as shown in the code below:
I = dicomread('C:\Users\Click Me\Desktop\NIELIT\images output\img.dcm');
info = dicominfo('C:\Users\Click Me\Desktop\NIELIT\images output\img.dcm');
Thus info contains patient data. I have used this part to produce key, IV and other inputs for AES-GCM algorithm. Then, as plaintext, I took the pixel data part, "I", as shown in the above code.
So then, I had the problem for encrypting data. I have written the code in such way that it takes,
A1=I(1:16)
A2=I(17:32)
A3=I(33:48)
A4=I(49:64)
Hence, I took the first 64 numbers of the matrix "I" and then did the encryption. So after encryption I have to concatenate the remaining numbers, and hence form the encrypted image. I have mentioned The size of I.
I would like to know, how to do the concatenation part of remaining bits in matlab.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 15 Avr 2018

0 votes

A1bits = reshape((dec2bin(typecast(A1, 'uint8'), 8) - '0').', 1, []);
This will be a row vector. Once you have done this up to A4 then you can do
[A1bits, A2bits, A3bits, A4bits]

13 commentaires

Darsana P M
Darsana P M le 15 Avr 2018
Sir, where should I place this step. So finally will I get an Image? can you please explain it?
Till now, as I said I got the cipher text as follows:
Cipher=num2cell(cipherr);
CIJ=cell2mat(Cipher);
kk=CIJ*(1/100);
lkj=image(kk);
mno=colormap(gray(256));
This is cipher. I have to concatenate this with the remaining bits of I.HIs the above step enough? >> cipher
cipher(:,:,1,1) =
FF1A
FF4E
FF32
FF91
FF73
FF74
FF71
FFB6
FF1F
FF36
FF78
FF0A
FFF4
FF21
FF39
FFDD
cipher(:,:,1,2) =
FF19
FF4D
FF31
FF92
FF70
FF77
FF72
FFB5
FF1C
FF35
FF7B
FF09
FFF7
FF22
FF3A
FFDE
cipher(:,:,1,3) =
FF0A
FF5E
FF22
FF81
FF63
FF64
FF61
FFA6
FF0F
FF26
FF68
FF1A
FFE4
FF31
FF29
FFCD
cipher(:,:,1,4) =
FF1E
FF4A
FF36
FF95
FF77
FF70
FF75
FFB2
FF1B
FF32
FF7C
FF0E
FFF0
FF25
FF3D
FFD9
cipher_bits = reshape( (dec2bin(typecast(reshape(hex2dec(cipher), 1, []), 'uint8'),8)-'0').', 1, []);
I_bits = reshape( (dec2bin(typecast(reshape(I, 1, []), 'uint8'),8)-'0').', 1, []);
[cipher_bits, I_bits]
Darsana P M
Darsana P M le 15 Avr 2018
Sir, I could run the above lines without any error. Please can you tell me which should I use to plot the image?Should I plot I_bits to get back the image?
Walter Roberson
Walter Roberson le 15 Avr 2018
I don't know.
You talk about having a DICOM image, I, of size 716 1000 3, which is plausible for a DICOM image, though not all that common as most DICOM images are grayscale. But color DICOM images do exist, such as for opthomology, so we'll keep going.
But then you talk about I(1:64) as being the first 64 bits. That would require that each entry be a single bit. Binary DICOM images do exist but they are not permitted for most DICOM modalities, and they never occur in RGB form.
So I have no idea what data type your DICOM image really is, so I cannot tell you how to reconstruct a stream of bits to create an appropriate image.
imdata=I;
imdata=rgb2gray(imdata);
F=fft2(imdata);
S=abs(F);
Fsh=fftshift(F);
s2=log(1+abs(Fsh));
I do all these operations and finally I assign s2=plaintext and do the operations.
size(s2)
ans =
716 1000
then I take A1,A2,A3,A4, and finally after encryption I get CIPH
cipherr_1=Cipher(1:16);
cipherr_2=Cipher(17:32);
cipherr_3=Cipher(33:48);
cipherr_4=Cipher(49:64);
CIPH=cat(4,cipherr_1,cipherr_2,cipherr_3,cipherr_4);
size(CIPH)
ans =
1 16 1 4
This CIPH, I have to concate such that I get an image of size s2?
Walter Roberson
Walter Roberson le 15 Avr 2018
For the code you show, the first 64 bits of s2 are stored in s2(1,1)
Ya so I took a variable say
j=(64:1000) {indicates remaining bits of s2}
And now I have cipher, can I concatenate cipher with j and get the image? if so how should I do?
Walter Roberson
Walter Roberson le 15 Avr 2018
No you cannot do that. Your cypher is only 64 bits but you are discarding the first 64*64= 4096 bits of the image, and what remains cannot be reformed into an array the same size as the image.
Darsana P M
Darsana P M le 15 Avr 2018
Sir so what should I do. Size of s2=716 1000.
Thus it has 716 rows and 1000 columns. This constitute the entire image. In this I have taken, first 64 numbers or elements from first row. Thus remaining (65:1000). Thus i get the first row.
Similarly, I have to get the 715 rows and 1000 columns.This together with the first onw will give me the entire image. An encrypted image.
What should be the matlab code to get the 64:1000 from firstrow and the remaining 715 rows?
Darsana P M
Darsana P M le 15 Avr 2018
f=s2(:,:)-s2(1:1000) Will something like this work out?
[YourMatrix(1,65:end), reshape(YourMatrix(2:end,:).', 1, [])]
However, I do not understand why you are taking the first 64 numbers or elements of the first row when you want the first 64 bits. Your array contains double precision precision numbers, so your elements are 64 bits each, so the first 64 of the first row would be 64 elements * 64 bits per element = 4096 bits. You are only producing a 64 bit hash, so you are losing 63*64 = 4032 bit positions in your output.
Darsana P M
Darsana P M le 16 Avr 2018
Thanks a lot for your response sir.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Encryption / Cryptography dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by