필터 지우기
필터 지우기

how can i creat image from data?

조회 수: 7 (최근 30일)
Sanaa
Sanaa 2016년 8월 22일
댓글: Image Analyst 2016년 8월 26일
hi I'm beginner in matlab my problem is how to get image.i have text data (row,col) and i want to create image from this data, and this image should be like fringes (dark and white line)
  댓글 수: 1
KSSV
KSSV 2016년 8월 22일
Attach the data here....

댓글을 달려면 로그인하십시오.

답변 (2개)

Farouk Moukaddem
Farouk Moukaddem 2016년 8월 26일
Hi,
Refer to the following documentation link for the "mat2gray" command that is used to convert a matrix to a grayscale image:
You will also find an example in the above link that will help you get started with Image Processing applications.
Best,
Farouk
  댓글 수: 1
Sanaa
Sanaa 2016년 8월 26일
Hi sir Thanks for replying but I have data not image according to your link I should read the image for my case I didn't have ,I got results and that's results is text file contain four cols (r,theta,phi,intensity) and I should generate image like sphere (like ball) Thanks

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2016년 8월 26일
Try this (untested):
% In advance, read your text data into three vectors,
% rows and columns and grayLevels. Then...
lastRow = max(rows);
lastCol = max(columns);
grayImage = zeros(lastRow, lastCol, 'uint8');
for k = 1 : length(rows)
grayImage(rows(k), columns(k)) = grayLevels(k);
end
This assumes that rows and columns are integers.
  댓글 수: 4
Sanaa
Sanaa 2016년 8월 26일
I tried also this code but it isn't work,
clc
clear;
fid = fopen('fort (1).130');
tline = fgets(fid);
out=[];
while ischar(tline)
a=sscanf(tline,' The Time-averaged Poyntine vector(W/m*m) at point: %f');
tline = fgets(fid);
[b c]=sscanf(tline,'%f %f');
tline = fgets(fid);
[d]=sscanf(tline,' Psca %f');
tline = fgets(fid);
out=[out;a b(1) b(2) d];
end
fclose(fid);
% load ('out.mat')
r= out(:,1);
theta= out(:,2);
phi= out(:,3);
I= out(:,4);
theta_new=theta.*180./pi;
for i=1:length(theta_new)
r_a=r(i);
theta_new_a=theta_new(i);
phi_a=phi(i);
x = r(i) .* cos(phi(i)) .* cos(theta_new(i));
y = r(i) .* cos(phi(i)) .* sin(theta_new(i));
% z = r_a .* sin(phi_a);
I(x,y)=I(i);
% x = rcosthetasinphi
% y = rsinthetasinphi
% z = rcosphi.
%
%
end
I=uint8(I);
imshow(I)
Image Analyst
Image Analyst 2016년 8월 26일
I think you overlooked the last line of my answer. Here it is again:
And THIS LINK and attach your data file if you want us to try to run your code.
Not really sure why you did not attach your data -- did you just forget, or am I to just assume that you don't want us to run your code with your data?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by