>
clc; A=imread('C:\Users\hp\Desktop\matlab\pictures\lenna.png');%sample image rnd_x = randperm(size(A,1)-128,7);%choose 7 random unique points on x-axis rnd_y = randperm(size(A,2)-128,7);%choose 7 random unique points on y-axis image(A) for ii = 1:4 for jj = 5:7 piece{jj} = A((rnd_x(jj):(rnd_x(jj)+127)),(rnd_y(jj):(rnd_y(jj)+127)),1:3)+100; figure(jj) a=imadjust(jj); imshow(piece{jj}); end piece{ii} = A((rnd_x(ii):(rnd_x(ii)+127)),(rnd_y(ii):(rnd_y(ii)+127)),1:3)-100;%Convert chosen numbers to image pieces figure(ii) b=imadjust(ii); imshow(piece{ii}); end imshow(A)
I understand that you want to take 7 patches of size 127X127 from the original image and make 3 of them lighter by adding 100 to there pixel values and 4 of them darker by subtracting 100 from there pixel values. You are not able to see any change in the image ‘A’ as you didn’t make any changes on it, rather stored the changed pixel values in ‘piece’. You can try this modified code.
clc; A=imread('C:\Users\hp\Desktop\matlab\pictures\lenna.png');%sample image rnd_x = randperm(size(A,1)-128,7);%choose 7 random unique points on x-axis rnd_y = randperm(size(A,2)-128,7);%choose 7 random unique points on y-axis image(A) for ii = 1:4 for jj = 5:7 piece{jj} = A((rnd_x(jj):(rnd_x(jj)+127)),(rnd_y(jj):(rnd_y(jj)+127)),1:3)+100; A((rnd_x(jj):(rnd_x(jj)+127)),(rnd_y(jj):(rnd_y(jj)+127)),1:3)= piece{jj}; % add the changed pixel values to the original image A figure(jj) a=imadjust(jj); imshow(piece{jj}); end piece{ii} = A((rnd_x(ii):(rnd_x(ii)+127)),(rnd_y(ii):(rnd_y(ii)+127)),1:3)-100;%Convert chosen numbers to image pieces A((rnd_x(ii):(rnd_x(ii)+127)),(rnd_y(ii):(rnd_y(ii)+127)),1:3)= piece{ii}; % add the changed pixel values to the original image A figure(ii) b=imadjust(ii); imshow(piece{ii}); end imshow(A)
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.