I have an encrypted image,I wantit to like these so I can be able to test for data loss

7 件のコメント

Jan
Jan 2022 年 10 月 15 日
"I wantit to like these" - this is not sufficient to clearify, what you want to achieve. Which details matter? What are the inputs? What have you tried so far? which Matlab realted problems did occur?
dani elias
dani elias 2022 年 10 月 15 日
Hello. The image is encrypted,I have managed to recover the image to its original form when I applied salt&pepper noise,speckle noise and Poisson noise. Then assume there is about 25% of data loss(black area) as shown in the picture or whatever %. What are the MATLAB codes I can use to plot that black area?
Jan
Jan 2022 年 10 月 15 日
@dani elias: "The image is encrypted,I have managed to recover the image to its original form when I applied salt&pepper noise,speckle noise and Poisson noise." - you procide information, which does not have a relation to the problem, but important details, which would clarify the problem are still missing.
What are your inputs? "Encrypted images" is less clear than: uint8 RGB arrays? uint16 grayscale matrices? logical binary matrices?
Do you want to plot the black area? Then it is visible on the screen. I assume you want to set a square (or almost square, 25% need not be an integer) block of data to 0 (not "black")?
Then a compact and exhaustive version of your question would be:
data = randi([0, 255], 400, 400, 'uint8');
How to set an almost square block in the center to 0, which occupies X% of the pixels?
dani elias
dani elias 2022 年 10 月 15 日
編集済み: Walter Roberson 2022 年 10 月 15 日
Sorry for my bad explanation,but after read your comments now I can explain in a better way. assume you have a square image uint8, gray-scale. I want to insert a rectangle (we refer this as data loss in terms of % covered). For example
A=imread('jojo.bmp');
A=insertShape(A,'filledrectangle',[15 28 75 65],'Color',{black},Opacity=0.7);
Figure,imshow(A);
Here,I insertes rectangle using coordinates.is there any means of covering the image using rectangle in % form? (for example 25% is covered,or 10% is covered) How can I do that?
Walter Roberson
Walter Roberson 2022 年 10 月 15 日
No, MATLAB does not provide any functions that alter arrays based upon percentage sizes. You will need to take size() of the rectangle and multiply by the fraction to arrive at the target sizes.
dani elias
dani elias 2022 年 10 月 15 日
Thank you
Jan
Jan 2022 年 10 月 16 日
Remember that insertShape replies an RGB image.

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2022 年 10 月 16 日

0 投票

Try this on your recovered image
% Create "recovered" image.
grayImage = imread('cameraman.tif');
grayImage = imnoise(grayImage, "gaussian", 0, .01);
[rows, columns, numberOfColorChannels] = size(grayImage)
rows = 256
columns = 256
numberOfColorChannels = 1
subplot(2, 1, 1);
imshow(grayImage, []);
title('Initial Image')
% Define fraction of pixels to blacken in the middle.
pct = 0.25;
% Determine how many pixels that is.
numBlackPixels = pct * numel(grayImage)
numBlackPixels = 16384
% Assume it's a square and determine the width of the square
squareWidth = sqrt(numBlackPixels)
squareWidth = 128
% Get the rows of the square in the original image
row1 = round(rows/2 - squareWidth/2)
row1 = 64
row2 = round(rows/2 + squareWidth/2)
row2 = 192
% Get the columns of the square in the original image
col1 = round(columns/2 - squareWidth/2)
col1 = 64
col2 = round(columns/2 + squareWidth/2)
col2 = 192
% Do the blackening:
grayImage2 = grayImage; % Initialize
grayImage2(row1:row2, col1:col2) = 0; % Blacken square in the middle
subplot(2, 1, 2);
imshow(grayImage2, [])
title('Output Image')

1 件のコメント

dani elias
dani elias 2022 年 10 月 16 日
Thank you, this works perfect.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2022 年 10 月 15 日

コメント済み:

2022 年 10 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by