adjacent pixel before and after encryption
Afficher commentaires plus anciens
- I wonder if my result of the adjacent pixel is correct before and after encryption for vertical, horizontal. I'm also including the histograms of my encryption image, with the image results.
17 commentaires
Image Analyst
le 31 Déc 2020
None of those images display in my Firefox browser.
I have no idea what the correctly encrytped value would be in any pixel. Besides, we're not allowed to discuss encryption in this forum.
I suggest you just follow normal debugging procedures like setting breakpoints, stepping through line-by-line, examining variable values in the workspace panel, etc. I mean, you can probably do that with your code better than we can.
assaad el makhloufi
le 31 Déc 2020
Walter Roberson
le 31 Déc 2020
We wouldn't know -- we do not have the original image.
assaad el makhloufi
le 31 Déc 2020
Walter Roberson
le 31 Déc 2020
Firefox cannot display the image I indicated - though it appears that MacOS "Preview" can display it.
You had already uploaded Original image histo.jpg -- it is the original image itself that we do not have.
assaad el makhloufi
le 31 Déc 2020
Image Analyst
le 31 Déc 2020
OK the images display now.
OK, let's take an arbitrary pixel at (row, column) = (2,2). Now, what do you consider the "adjacent" pixels? The 8 neighboring pixels at (1,2), (1,2), (1,3), (2,1), (2,3), (3,1), (3,2), and (3,3)? Ok, let's assume those 8 neighboring pixels are the pixels "adjacent" to the pixel at (2,2). And of course, we'll have 3 images I presume:
- the original image
- the encrypted image (IF it's even in a rectangular (row, column) format), and
- the decrypted image (which should match the original image).
Now exactly what comparisons do you want to do between the 8 adjacent pixels and a pixel at a given location among the 3 images (9*3=27 pixels in total, times the number of pixels in the image, like a million or whatever)?
I'd say your encryption/decryption algorithm is correct is a round trip gives you the original image exactly.
assaad el makhloufi
le 31 Déc 2020
Modifié(e) : assaad el makhloufi
le 31 Déc 2020
Walter Roberson
le 31 Déc 2020
P = imread('orig.PNG');
if ndims(P) > 2; P = rgb2gray(P); end
hadj = accumarray(1+[reshape(P(:,1:end-1),[],1), reshape(P(:,2:end),[],1)], 1, [256,256]);
hver = accumarray(1+[reshape(P(1:end-1,:),[],1), reshape(P(2:end,:),[],1)], 1, [256,256]);
subplot(2,1,1)
surf(hadj, 'edgecolor', 'none')
title('horizontal')
subplot(2,1,2)
surf(hver, 'edgecolor', 'none')
title('vertical')
This has a slight bias: it counts from one pixel to the next one with higher index, but it does not count from higher index to lower. For example if the last column was the only column that had pixel value 99, then you would get 99's on the y axes, but would not get any 99 on the x axes.
assaad el makhloufi
le 31 Déc 2020
Image Analyst
le 31 Déc 2020
Are you by chance really after the GLCM, but just didn't know the name of it?? That's the gray level cooccurrence matrix. If so, see attached demo.
Because I don't see any encryption going on, like DES or whatever.
Walter Roberson
le 1 Jan 2021
The resolution of example.JPG is too low for me to read.
assaad el makhloufi
le 1 Jan 2021
Image Analyst
le 1 Jan 2021
You should never us jpg images for image analysis. Your image looks like it should be an image with only 2 gray levels. You wouldn't use GLCM on a binary image since it's rather meaningless. It's meant for gray scale images. You have a gray scale image because you mistakenly used a JPG image, so in stead of just the 2 gray levels like you expect, you have alots of gray levels due to JPG being a lossy compression method and it changing the gray levels. And you can see that in the GLCM. Instead of just signal at two points representing the two gray levels, you have a cluster of points representing differences between each pixel and its adjacent neighbors. These differences are not all 1 or zero like they'd be with a binary image.
But anyway, that was jsut a guess because I can't really figure out what you're after when you ask "if my result of the adjacent pixel is correct before and after encryption for vertical, horizontal" Still not sure what you mean by encryption, adjacent, and correct.
assaad el makhloufi
le 1 Jan 2021
Walter Roberson
le 1 Jan 2021
Yes, use png or bmp images.
Image Analyst
le 1 Jan 2021
Yes, in general, but then like I said you wouldn't use GLCM I don't think, but maybe you would. Try it and see. But with a binary image like you have the difference between adjacent pixels will always be 0 or some other single number (the gray level difference). Still not sure what you're after because you didn't explain any of me questions in the last paragraph.
Réponses (1)
assaad el makhloufi
le 1 Jan 2021
0 votes
6 commentaires
Walter Roberson
le 1 Jan 2021
Go ahead. I already showed you how to calculate the horizontal and vertical counts in https://www.mathworks.com/matlabcentral/answers/706173-adjacent-pixel-before-and-after-encryption#comment_1238098 . It is not difficult to adjust that for diagonal as well.
assaad el makhloufi
le 1 Jan 2021
Walter Roberson
le 2 Jan 2021
On one axis you have the 256 different grayscale levels as the first element of the pair of pixels. On a second axis you have the 256 different grayscale levels as the second element of the pair of pixels. Now you say that you want a histogram. Histograms involve counts of the number of times circumstances occur, and representing the counts as a dimension. So you have 3 dimensions: source grayscale, destination grayscale, and counts. That requires a 3d graph, not a 2d graph. The plots you show are scatter plots, not histograms, and show only whether a combination occurs, with no information about how often it occurs.
You need to make a decision: do you want histograms like you asked for, or do you want scatter plots like your sample images? Or you could scatter but represent the count as color.
assaad el makhloufi
le 2 Jan 2021
Modifié(e) : assaad el makhloufi
le 2 Jan 2021
Image Analyst
le 2 Jan 2021
If you really want to know how many times graylevel1 occurs next to graylevel2, in each direction, then you can use graycomatrix(), like the attached example.
assaad el makhloufi
le 2 Jan 2021
Catégories
En savoir plus sur Texture Analysis dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!