Change or save data .txt

1 visualización (últimos 30 días)
Akmal Rahmat
Akmal Rahmat el 22 de Nov. de 2014
Comentada: Image Analyst el 23 de Nov. de 2014
a = dlmread('test4.txt');
b = dlmread('test5.txt');
if (a-b)>125
c = (a-b)>125;
c = 0;
c = dlmmwrite('test4.txt','delimiter');
c = dlmwrite('test5.txt','delimiter');
end
hello all. i need help.here is my code. how do i change the data in my .txt file ? when a-b meet my condition i want to change it in both .txt file. i keep getting error. please help me. thank you
  5 comentarios
Akmal Rahmat
Akmal Rahmat el 22 de Nov. de 2014
here is the text file. i want to change both file value when it meet the condition where the a-b value more than 125 then the number in the txt file will change to zero.
Guillaume
Guillaume el 22 de Nov. de 2014
Editada: Guillaume el 22 de Nov. de 2014
If you'd answered the question I asked we would be much closer to helping you. So, once again, if
a = [255 255 0 124 126]
b = [255 0 255 126 124]
What final a and b do you expect? Bearing in mind that:
(a-b) == [0 255 -255 -2 2]

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 22 de Nov. de 2014
Editada: Image Analyst el 22 de Nov. de 2014
Try this (untested because you didn't attach your text files):
a = dlmread('test4.txt');
b = dlmread('test5.txt');
c =(a-b)>125; % Logical array
a(c) = 0; % Replace elements in a with 0;
b(c) = 0; % Replace elements in b with 0;
% Write updated a and b back out.
dlmwrite('test4.txt', a);
dlmwrite('test5.txt', b);
  10 comentarios
Akmal Rahmat
Akmal Rahmat el 22 de Nov. de 2014
a and b are different sizes ? i just resize a to 100x100 and rename it as b ? is my code right?
originally my task is to compare two image that been convert to text file. i attach the image that i will use. all i want is to read each value in both text file then make comparison of it and show the percentage of different between two text file.
a = imread('img2.jpg');
b = imresize(a,[100,100])
dlmwrite('test4.txt', b, 'delimiter', ',');
d = dlmread('test4.txt');
e = imread('img1.jpg');
f = imresize(e,[100,100])
dlmwrite('test5.txt', f, 'delimiter', ',');
g = dlmread('test5.txt');
here is my way to convert the image to text file. the problem is how to calculate the different between two text file. sir do you have any idea how i should do it. i am stuck here.
Image Analyst
Image Analyst el 23 de Nov. de 2014
Use my code in the comment, but have C be this:
c = a ~= b; % Logical array
This will calculate where a and b are different, like you asked for.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by