Azzera filtri
Azzera filtri

How to remove the lines in the image?

10 visualizzazioni (ultimi 30 giorni)
Here is my coding, can anyone help me edit my coding to remove the lines inside the image?This is very annoying >.<
I'm actually converted from the text file.
The image should be 224x224x3
The text file is 1x150528
fid = fopen('output_data_1.txt','r');
img = fscanf(fid,'%x');
outImg = reshape(img,[224*1 224*3]);
outImg = outImg';
  2 Commenti
KALYAN ACHARJYA il 15 Ago 2019
Modificato: KALYAN ACHARJYA il 15 Ago 2019
Which lines? If you do sort of operation on lines pattern, then image may turn dark gray image.??
Remove lines from the image, then fill the vacant location by??
Geoff Hayes
Geoff Hayes il 15 Ago 2019
Tham - please don't post duplicate questions. This is a continuation of your where the problem is due to the outImg being reshaped incorrectly. According to your initial post, the image should be 224x224x3. In the above, you have created a 224x672 image.

Accedi per commentare.

Risposta accettata

Sourav Bairagya
Sourav Bairagya il 19 Ago 2019
Modificato: Sourav Bairagya il 19 Ago 2019
After inspecting the script that you are using, it seems that data stored in the “input_data.txt” is stored in channels first format. Instead of reshaping the data into 224X672 image, you should reshape it into 3X224X224 image.
Now, to display the image using imshow, the input file must be of size MXNX3. Hence, in this case, desired dimension is 224X224X3.
To get that desired dimension one option is to extract all the channels separately, and then concatenate them in order to get back the actual image. Make sure that the datatype of image data is of “uint8”.
Another option is to use “permute” function, in which it is possible to re-arrange the dimensions as per desired order.
Finally, the image which is obtained is a transposed version of the original one. To get back the actual image, you should use the permute function again to transpose it.
The whole code is as follows:
fid = fopen('input_data.txt','r');
img = fscanf(fid,'%d');
outImg = uint8(reshape(img,[3 224 224]));
outImg1=uint8(reshape(outImg(1,:,:),[224,224])); %Extracting the channels separately
RGB = cat(3,outImg1,outImg2,outImg3); %Concatenation of all the channels
%RGB = permute(outImg,[2 3 1]); %Instead of using above four lines, you
%Can also use this line to reshape the data
%in 224X224X3 i.e. channels last format.
RGB = permute(RGB,[2 1 3]); %This is to transpose the color image
Actual image has 3 channels and of the size 224X224X3 and in your code the output image was of size 224X672. As you were merging independent pixel data from all the 3 channels in 2nd dimension, hence those undesired lines were turning up in the output image due to overlap of all those different channel data.
To know more information about permute function and imshow function follow these links:

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by