0

i have a question given for me.in that the objective is to encrypt the image to some noise and at last have to get 50% black shade on that image.i have done till the encryption.can anyone tell me how to get 50% darkshade in it.

clc;
clear all;
close all;
a=imread('lenna.jpg');
%figure,imshow(a);
b=rgb2gray(a);
figure,imshow(b);
c=double(b);
%figure,imshow(c);
d=randn(512,512);
e=exp(2*pi*i*d);
f=c.*e;
%figure,imshow(f);
g=fft2(f);
h=randn(512,512);
s=exp(2*pi*i*h);
j=g.*s;
k=fft2(j);
figure,imshow(k);

here k is the encrypted image.now what i need is to change this image 50% to black colour.the image is 512px.can anyone help?

Alec
  • 1,178
  • 5
  • 20
  • Do u have some example input and output images of what u want to achieve? – Marcin Aug 14 '13 at 07:10
  • What do you mean by "change this image 50% to black colour"? ` Have you tried `imshow(0.5*k)`? – Luis Mendo Aug 14 '13 at 09:22
  • possible duplicate of [how to covert 1/4 elements of a matrix to zero](http://stackoverflow.com/questions/18214965/how-to-covert-1-4-elements-of-a-matrix-to-zero) – MZimmerman6 Aug 14 '13 at 14:01

1 Answers1

0

This should do it:

for i=1:512
  indices = randi(512,256,1);
  k(indices,i) = 0;
end

It selects 256 pixels of each row (that is, 50%) and sets them to zero. I put it in a for-loop because randi(512^2,512^2/2) might have memory issues...