Home > other >  (MATLAB) bosses to help, the second code like know in front of me to do, widen my image grey value t
(MATLAB) bosses to help, the second code like know in front of me to do, widen my image grey value t

Time:04-20

The thing is, below is a greyscale image, I want to widen the image below article exposure, at the same time reduce the gray value of background, but I design code article exposed the other area causes noise, exposure is not belong to a part of the article will also because of the grey value and exposure and be retained,
Then I thought, because of the noise distribution is discrete, the exposure of the gray level values are in an area and uniform, so I just according to this condition design code, as long as is not in conformity with the article exposure conditions, to I reduce the grey value,
But something strange happened, noise is eliminated, but before I widened part was also lower gray!
I thought this is because I think I widened the code part outside the article belongs to the exposure area as well, so I design the following two code, reduce the widening regional and background gray code is divided into two boxes, and widen the areas after the save as. PNG figure, then use this picture to reduce background gray,
But equally strange things happened again, and this is really weird, run after the second code, I widened the part of the gray level are lower, and know that I like the second code first code to do the same, for the second code, it is be widened after the processing of images, looks and processing images of the first code, exposure is just the fat,
But it is just because of the logic is right, the second piece of code or accurate found I widened section, and cut its gray value by a third,,, my god, so big not seen such a strange thing, if this is true, this is nothing less than double-slit as bizarre,
Strives for the big help, and see where I go wrong? I would rather believe that I was wrong, don't believe such a strange thing, I feel I received through the challenge,,,

Code a
% * * * * * * * * * to enhance the overall contrast of the image, and use a for loop traverse pixels. PNG version
% %
clc;
clear;
close all;
tic; % calculation program running time
CD (' E: \ \ office \ post-graduate study in recent years, research direction, the new study, the workspace \ \ OI the night sky figure OI the night sky classification \ \ after adjust contrast with imadjust function to adjust the contrast of ') % 1219 folders for raw file path changes (flexible)
Oldpath=CD;
Filepath=oldpath;
CD (filepath)
Filename1=ls (' *. PNG '); % reads all the PNG file, filename1 is a matrix, each row is a filename, line number for the file number,
Filename2=ls (' *. PNG ');
The size (filename2)
For I=1: size (filename1, 1) % size (filename1, 1) represent filename1 rows,
B=filename1 (I);
A=imread (b);
The row=size (a, 1); % the image line
Col=size (a, 2); % of the image list
T=254; % grey value threshold (threshold)
For k=1:1: row - 8
For m=1:1: col - 8
If a (k, m) & gt; T& & A (k + 1, m) & gt; T& & A (k + 2 m) & gt; T& & A (k + 3 m) & gt; T& & A (k + 4 m) & gt; T& & A (k + 5 m) & gt; T& & A (k + 6 m) & gt; T& & A (k + 7 m) & gt; T& & A (k + 8 m) & gt; t ...
& & A (k, m + 1) & gt; T& & A (k, m + 2) & gt; T& & A (k, m + 3) & gt; T& & A (k, m + 4) & gt; T& & A (k, m + 5) & gt; T& & A (k, m + 6) & gt; T& & A (k, m + 7) & gt; t ...
& & A (k + 1, m + 1) & gt; T& & A (k + 2, m + 2) & gt; T& & A (k + 3 m + 3) & gt; T& & A (k + 4 m + 4) & gt; T& & A (k + 5 m + 5) & gt; T % the article exposed the status quo in high brightness state

A (k, m + 6: m + 17)=a (k, m); % bold line exposure article
A (k, m)=a (k, m) * 1;
The else
A (k, m)=a (k, m) * 1; % to the background of grey value is 3.3 times lower
End
End
End

STR=strcat (' E: \ \ office \ post-graduate study in recent years, research direction, the new study, the workspace \ \ OI the night sky figure OI the night sky classification, after adjust the contrast, on the basis of the imadjust function to manually adjust the contrast \ 0101 \ ', filename2 (I, :)); % hexadecimal conversion is completed, the resulting images saved location for 1218 folder (flexible changes),
Imwrite (a, STR); % to write image data into the image file, (drawing)
End
CD (oldpath)
! Echo mission completed!
toc;

Code 2
% * * * * * * * * * to enhance the overall contrast of the image, and use a for loop traverse pixels. PNG version
% %
clc;
clear;
close all;
tic; % calculation program running time
CD (' E: \ \ office \ post-graduate study in recent years, the research direction, the new study, the workspace \ \ OI the night sky figure OI the night sky classification, after adjust the contrast, on the basis of the imadjust function to manually adjust the contrast \ '0101) % 1219 folders for raw file path changes (flexible)
Oldpath=CD;
Filepath=oldpath;
CD (filepath)
Filename1=ls (' *. PNG '); % reads all the PNG file, filename1 is a matrix, each row is a filename, line number for the file number,
Filename2=ls (' *. PNG ');
The size (filename2)
For I=1: size (filename1, 1) % size (filename1, 1) represent filename1 rows,
B=filename1 (I);
A=imread (b);
The row=size (a, 1); % the image line
Col=size (a, 2); % of the image list
T=254; % grey value threshold (threshold)
For k=1:1: row - 8
For m=1:1: col - 8
If a (k, m) & gt; T& & A (k + 1, m) & gt; T& & A (k + 2 m) & gt; T& & A (k + 3 m) & gt; T& & A (k + 4 m) & gt; T& & A (k + 5 m) & gt; T& & A (k + 6 m) & gt; T& & A (k + 7 m) & gt; T& & A (k + 8 m) & gt; t ...
& & A (k, m + 1) & gt; T& & A (k, m + 2) & gt; T& & A (k, m + 3) & gt; T& & A (k, m + 4) & gt; T& & A (k, m + 5) & gt; T& & A (k, m + 6) & gt; T& & A (k, m + 7) & gt; t ...
& & A (k + 1, m + 1) & gt; T& & A (k + 2, m + 2) & gt; T& & A (k + 3 m + 3) & gt; T& & A (k + 4 m + 4) & gt; T& & A (k + 5 m + 5) & gt; T % the article exposed the status quo in high brightness state

A (k, m)=a (k, m) * 1;
The else
A (k, m)=a (k, m)/3.3; % to the background of grey value is 3.3 times lower
End
End
End

STR=strcat

The results of the code a figure
The result of the code 2 figure
  • Related