Skip to content

Commit

Permalink
[0.5.1] Added: Pixel3DArrayToRGBChannelArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Luzkan committed Oct 29, 2021
1 parent 2d587d5 commit 054dbb4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
18 changes: 14 additions & 4 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [[0.5.1]] - 2021-10-29 _(MJ)_

###### _([diff: 0.5.0-0.5.1])_

Added:

- `pixel3DArrayToChannelArray()` implementation in [`histogram-shifting.js`](../src/algorithms/histogram-shifting.js)

## [[0.5.0]] - 2021-10-26 _(JW)_

###### _([diff: 0.4.1-0.5.0])_

Added:

- [_Reversible Data Hiding_](./docs/papers/Reversible_data_hiding.pdf) - a paper on histogram shifting
- Directory `/src/algorithms/` with three javascript files containg basic structure of three chosen encryption methods
- [_Reversible Data Hiding_](./docs/papers/Reversible_data_hiding.pdf) - a paper on histogram shifting
- Directory `/src/algorithms/` with three javascript files containg basic structure of three chosen encryption methods

Changed:
Changed:

- `main.js` now invokes the (not yet finished) encryption methods of the `/src/algorithms/` directory instead of the sample methods from `/src/algorithms.js` (which was removed)
- `main.js` now invokes the (not yet finished) encryption methods of the `/src/algorithms/` directory instead of the sample methods from `/src/algorithms.js` (which was removed)

## [[0.4.1]] - 2021-10-26 _(MJ)_

Expand Down Expand Up @@ -147,6 +155,7 @@ Added:
- Created [**`CHANGELOG.md`**](../docs/CHANGELOG.md) for the project that contains the history of changes for this project.
- Created [**`README.md`**](../README.md) for the project that contains various useful information, requirements and instructions in order ot run the program.

[diff: 0.5.0-0.5.1]: https://github.com/Luzkan/CryptoImage/compare/0.5.0...0.5.1
[diff: 0.4.1-0.5.0]: https://github.com/Luzkan/CryptoImage/compare/0.4.1...0.5.0
[diff: 0.4.0-0.4.1]: https://github.com/Luzkan/CryptoImage/compare/0.4.0...0.4.1
[diff: 0.3.0-0.4.0]: https://github.com/Luzkan/CryptoImage/compare/0.3.0...0.4.0
Expand All @@ -155,6 +164,7 @@ Added:
[diff: 0.1.0-0.1.1]: https://github.com/Luzkan/CryptoImage/compare/0.1.0...0.1.1
[diff: 0.0.1-0.1.0]: https://github.com/Luzkan/CryptoImage/compare/0.0.1...0.1.0
[diff: 0.0.0-0.0.1]: https://github.com/Luzkan/CryptoImage/compare/0.0.0...0.0.1
[0.5.0]: https://github.com/Luzkan/CryptoImage/releases/tag/0.5.1
[0.5.0]: https://github.com/Luzkan/CryptoImage/releases/tag/0.5.0
[0.4.1]: https://github.com/Luzkan/CryptoImage/releases/tag/0.4.1
[0.4.0]: https://github.com/Luzkan/CryptoImage/releases/tag/0.4.0
Expand Down
35 changes: 30 additions & 5 deletions src/algorithms/histogram-shifting.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,39 @@ function histogramShiftingEncrypt(pixel3DArray) {

channelArray.forEach(encryptInChannel)

return channelArrayToPixel3DArray(channelArray)
return channelArrayToPixel3DArray(pixel3DArray)
// return channelArrayToPixel3DArray(channelArray)
}

function pixel3DArrayToChannelArray(pixel3DArray) {

// convert pixel 3D array to three arrays representing R, G and B pixel values
class RGB {
constructor(idx, red, green, blue, transparency) {
this.idx = idx;
this.red = red;
this.green = green;
this.blue = blue;
this.transparency = transparency;
}
}

function pixel3DArrayToChannelArray(pixel3DArray) {
let RGBChannelArray = [];
let pixelIterator = 0;

for (let channel in pixel3DArray) {
for (let pixel in pixel3DArray[channel]) {
RGBChannelArray.push(new RGB(
pixelIterator,
pixel3DArray[channel][pixel][0],
pixel3DArray[channel][pixel][1],
pixel3DArray[channel][pixel][2],
pixel3DArray[channel][pixel][3]
));
pixelIterator += 1;
}
}

return [[], [], []];
return RGBChannelArray;
}

function encryptInChannel(channel) {
Expand Down Expand Up @@ -60,6 +85,6 @@ function channelArrayToPixel3DArray(channelArray) {

// convert three channel arrays to a pixel 3D array

const temporaryUpsideDownImage = pixel3DArray.reverse();
const temporaryUpsideDownImage = channelArray.reverse();
return encodeBMPFrom3dData(temporaryUpsideDownImage);
}

0 comments on commit 054dbb4

Please sign in to comment.