Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

I want explanation for this code GIVEN BELOW ?

1 view (last 30 days)
venmal devi
venmal devi on 18 Oct 2015
Closed: John D'Errico on 18 Oct 2015
clc;
clear all;
close all;
I1=imread('nature1.jpg','jpg');
figure(1);imshow(I1,[]);title('gray image');
%set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
%I=genpath;
%P=imread('I');
figure(2);imhist(I1);title('HISTOGRAM OF GRAY IMAGE');
%zpoint(I,ADJ );
I2=imread('nature2.jpg','jpg');
%figure
%set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
figure(3);imshow(I2);title('COLOUR IMAGE');
I2conv=rgb2gray(I2);
imhist(I2conv);title('HISTOGRAM OF COLOR IMAGE')
%%check number of channels
if size(I1, 3) ~= 1
I1 = rgb2gray(I1);
I1=wiener2(I1,[5 5]);
figure(4);imshow(I1);title('a');
end
if size(I2, 3) ~= 3
error('img2 must be a color image (not indexed)');
end
%%convert to ycbcr
Y1 = rgb2ycbcr(I1(:, :, [1 1 1]));
Y2 = rgb2ycbcr(I2);
%%normalize
Y1d = double(Y1(:, :, 1));
Y2d = double(Y2(:, :, 1));
Y2n = Y2d(:) /(1 - range(Y2d(:)) / 255) * (1 - range(Y1d(:)) / 255);
Y1n = Y1d(:) /(1 - range(Y2d(:)) / 255) * (1 - range(Y1d(:)) / 255);
%%build luminancetransform
BLT = zeros(256, 1);
for y1 = 0 : 255
[val, idx] = min(abs(Y2n - Y1n(1:24300)));
BLT(y1 + 1) = idx(1);
end
%%compare luminance
idx = BLT(Y1d + 1);
Y2_2 = Y2(:, :, 2);
Y2_3 = Y2(:, :, 3);
nimage = cat(3, Y1(:, :, 1), Y2_2(idx), Y2_3(idx));
rgb = uint8(ycbcr2rgb(nimage));
I3=imhistmatch(rgb,I2);
%I3=histeq(I2,256);
figure(6);imshow(I3);title('FINAL IMAGE');
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
  2 Comments
Martin Schätz
Martin Schätz on 18 Oct 2015
Hi, can you format your code? I don't understand what is commented there and what is code.
John D'Errico
John D'Errico on 18 Oct 2015
No. Sorry, but be serious.
This is a large piece of code, not just a tiny fragment. To ask what the entire mess does, in detail would take days to write, depending on how little or much you understand of MATLAB. This could take a MATLAB text as well as basic color and imaging science texts to explain fully.
So if you have not a clue as to what any of the code does, then DO SOME READING. Why are you wanting to understand code that is a complete black box to you anyway?
Once you spend some time reading the code yourself, then feel free to ask a specific question about the code, about ONE piece of it.

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!