Thursday, 27 June 2013
Wednesday, 26 June 2013
IMAGE FILE TO TEXT FILE CONVERSION MATLAB – TEXT FILE TO IMAGE FILE CONVERSION MATLAB EXAMPLE
By Unknown at Wednesday, June 26, 2013
IMAGE FILE TO TEXT FILE CONVERSION MATLAB – TEXT FILE TO IMAGE FILE CONVERSION MATLAB EXAMPLE, image processing, MATLAB
9 comments
Here
is an example to convert an image into a text file in matlab, for processing in
HDL (verilog) or in someother tool. Also the text file is further converted into image
file.
An image is a 2D matrix. For converting into text file,
it needs to be converted into 1D matrix and then to text file using file
write in matlab. The image size is also a constraint, so it needs to be
fixed for conversion. Then converted to 1D matrix using reshape command. Then
write into text file.
A=imread('1.bmp');
B=rgb2gray(A);
disp('Image file read successful');
%figure,imshow(B),title('org');
C=imresize(B,[isize isize]);
figure,imshow(C),title('croped');
d=reshape(C,1,[]);
disp('Reshapping done');
fid = fopen('img.txt', 'wt');
fprintf(fid, '%8d\n', d);
disp('Text file write done');disp(‘ ‘);
fclose(fid);
For converting text file
into image, it needs to be converted from 1D matrix and then to image. The
image size must same as previous for processing text into image. Then converted
to 1D matrix using reshape command. Then write into text file.
·
First, the text file
is read using file
read as vector (1D matrix).
·
Then it has to be
converted to matrix.
·
Finally transpose to
complete it as image.
fidh = fopen('img.txt');
Ah = fscanf(fidh, '%g %g', [1 inf]);
disp('Text file read done');
fclose(fidh);
S1h= vec2mat(Ah,isize,isize);
disp('Vector conversion done');
%c=imresize(S1,[128 128]);
Sh= transpose(S1h);
Jh=uint8(Sh);
disp('Image is ready');
imwrite(Jh,['newimage','.jpg']);
figure,imshow(Jh),title('IMAGE form TEXT file');
OUTPUT:
If
you have any queries mail us to admin@elecdude.com
Viewers comments are
encouraged.
It helps us to do better.
Thank you.
Tuesday, 11 June 2013
Monday, 10 June 2013
INTERFACING MULTIPLE TEMPERATURE SENSORS TO AVR – LM35 ATMEGA8
By Unknown at Monday, June 10, 2013
avr, INTERFACING MULTIPLE TEMPERATURE SENSORS TO AVR – LM35 ATMEGA8, microcontroller
2 comments
Here
is a simple example to interface multiple temperature sensors to AVR (Atmega8)
microcontroller. Atmega8 is a High-performance,
Low-power Atmel®AVR® 8-bit Microcontroller Advanced RISC Architecture with 8KB
ISP flash, 1KB RAM, 512B EEPROM, Two 8-bit Timer/Counters with Separate
Prescaler, one Compare Mode, One 16-bit Timer/Counter with Separate Prescaler,
Compare Mode, and Capture Mode, Real Time Counter with Separate Oscillator, Three
PWM Channels, 6 multiplexed ADC channels with 10-bit resolution. We have used 2
channels to connect 2 LM35 linear temperature sensors to it.
Thursday, 6 June 2013
MATLAB FILE IO - Syntax - Example Read Write
By Unknown at Thursday, June 06, 2013
MATLAB, MATLAB FILE IO Syntax Example Read Write Code
No comments
This is a simple example for accessing text files in MATLAB. It is always a trouble to process a signal or image in HDL directly. Using this we can convert a signal or an image into a text file and can be used to process in HDL (verilog, VHDL), etc.
First the required commands for file io are described, followed by the code example for a sine wave write and read.
First the required commands for file io are described, followed by the code example for a sine wave write and read.