COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### save .txt and image

• Email
• Follow

```hi..

a have a code below, about image statistical..

------------------------------------------

d = dir('E:\MATLAB6p5\work\X-Ray\*.tif');
for k =1:length(d)
fname = d(k).name;
imshow(fname)

IM = imcrop;

background = imopen(IM,strel('disk',15));

I2 = imsubtract(IM,background);

level = graythresh(I);
image = im2bw(I,level);

bw = double(image)/255;

bw1 = bwmorph(bw,'close');	% do boundary closure
I3 = bwmorph(bw1,'fill');	% fill isolated empty pixels

IM2 = bwareaopen(I3,100,8);

label = bwlabel(IM2);	% label each connected region

idx = unique(label(label~=0));
nb = zeros(1,length(idx));

RGBlabel = label2rgb(label,'spring','c','shuffle');
figure('Name','Label Image')
imagesc(RGBlabel)
axis image

for n = 1:length(idx)
[r,c] = find(label==idx(n));
y(n) = mean(r);
x(n) = mean(c);
nb(n) = numel(find(label==idx(n)));
pct(n) = 100*nb(n)/numel(IM);
text(x(n),y(n),int2str(n));
grid on;
zoom on;
end

for n = 1:length(idx)
[u,v] = sort(-nb);
sortx = x(v);
sorty = y(v);
sortsize = nb(v);
sortpct = pct(v);
end

B = [v' sortx' sorty' sortsize' sortpct'];

figure('Name','Next Image')

mkdir('E:\Result Void Analysis',fname)

fid = fopen('table.txt','wt');
fprintf(fid,'\n\nVoid x y size pct%%\n\n');
fprintf(fid,' %3d %8.2f %8.2f %4d %8.2f\n\n',B');
fclose(fid)

end

----------------------------------------------

but, my problm are, how to save table.txt and output image RGBLabel
into directory that i've created in the code above..

thanks..

julie
```
 0
Reply jullgunit (59) 3/31/2005 5:42:23 AM

See related articles to this posting

```Take a look at:

help cd

to change the actual directory.
Or

dir=['E:\Result Void Analysis\',fname];
mkdir(dir)
file=[dir,'\','table.txt'];
fid = fopen(file,'wt');

But I guess the cd command is more convenient.

Regards,
Stefan
```
 0
Reply gonseaw (535) 3/31/2005 8:08:52 AM

```hi..

actually i dont understand about cd and i try to apply ur code,

dir=['E:\Result Void Analysis\',fname];
mkdir(dir)
file=[dir,'\','table.txt'];
fid = fopen(file,'wt');

fprintf(fid,'\n\nVoid x y size
pct%%\n\n');
fprintf(fid,' %3d %8.2f %8.2f %4d %8.2f\n\n',B');
fclose(fid)

but i got error..
Error in ==> F:\julie\emm2.m
On line 76 ==> mkdir(dir)

i'm saving this m-file in removable disk F
```
 0
Reply jullgunit (59) 3/31/2005 8:24:04 AM

```Hi,

try this :

fname=strrep(fname,'.tif','');
mkdir('E:\Result Void Analysis',fname);
f=fullfile('E:\Result Void Analysis',fname,'table.txt');
fid = fopen(f,'wt');
fprintf(fid,'\n\nVoid x y size
pct%%\n\n');
fprintf(fid,' %3d %8.2f %8.2f %4d %8.2f\n\n',B');
fclose(fid);

J�r�me
```
 0
Reply dutmatlab (3796) 3/31/2005 11:48:41 AM

```I forgot the RGBLabel variable :

fname=strrep(fname,'.tif','');
mkdir('E:\Result Void Analysis',fname);
f=fullfile('E:\Result Void Analysis',fname,'table.txt');
fid = fopen(f,'wt');
fprintf(fid,'\n\nVoid x y size
pct%%\n\n');
fprintf(fid,' %3d %8.2f %8.2f %4d %8.2f\n\n',B');
fclose(fid);

save(fullfile('E:\Result Void Analysis',fname,'RGBLabel.mat'), ...
'RGBLabel')

J�r�me
```
 0
Reply dutmatlab (3796) 3/31/2005 12:52:59 PM

```hi..jerome

i didn't try the code yet.. i have something else to ask.. do you
remember about the problem i told you before.. about how to detect
the middle area automatically??
now, i'm using :
IM = imcrop;
but i have to do it manually.. i cannot use:
I2 = imcrop(I,rect);
because the locations are not same.
do u have any idea..

thanks..

julie
```
 0
Reply jullgunit (59) 4/1/2005 8:03:06 AM

5 Replies
41 Views

Similar Articles

12/12/2013 2:28:24 PM
[PageSpeed]

Similar Artilces:

Saving image on clipboard to file, or a contextual menu with "Save image to file"?
I've found myself having to save an image from the clipboard to a file a few times lately and have done the following: 1) Open GraphicConverter 2) Create a new canvas of large size 3) Pasting the image 4) Cropping the canvas down to the image size 5) Saving I'd really like to do this in fewer steps. Is there an application or something that will let me save directly from the clipboard to a file? (I don't care what image format it saves as.) What about a contextual menu? What about a different application that will let me streamline the above process? Thanks! -Lotofun In ar...

Saving 2 images as desktop image?
How do you save 2 pictures as one image so you can put it on the desktop? For example, if I wanted 2 pictures side by side, saved as a jpeg, so I could use it as the desktop. I know there must be a way of doing it but can't figure it out. Thanks. ------------- To send email, replace "antispam" with "sympatico" Pidge wrote: > How do you save 2 pictures as one image so you can put it on the > desktop? For example, if I wanted 2 pictures side by side, saved > as a jpeg, so I could use it as the desktop. The technique is called montage, often mis-called colla...

automatically save all named layers as images (save for web)?
Hi, I have a psd file with several named layers. Is there any way to create a droplet or something that will go through each layer and save only that layer for the web (jpg or gif) and give the file name the name of the layer? I played around with the actions window a little but no luck. Thanks. jscher01@tufts.edu wrote: > Hi, > > I have a psd file with several named layers. Is there any way to > create a droplet or something that will go through each layer and save > only that layer for the web (jpg or gif) and give the file name the > name of the layer? I played ar...

Saving images
Hi, How can I use the StreamInput and the StreamOutput classes in order to save images from an URL to the user directory? suppose I have: URL imageURL = getURL(image); .........? thanks,] Marcelo Marcelo wrote: > How can I use the StreamInput and the StreamOutput Huh? Are they new to Java 1.6? I don't see them here.. <http://java.sun.com/j2se/1.5.0/docs/api/allclasses-frame.html> >.. classes in order to > save images from an URL to the user directory? > > suppose I have: > URL imageURL = getURL(image); > > .........? If I supposed you had that...

saving an image
Hi everyone, Suppose I have displayed an image and then used hold on to overlap another image onto the first one. How can I store this final image which has the original and the overlapped image? After storing I want to retrieve it in the same code. I do not want to save the image and then use imread each time. I want this final image to be stored automatically into some variable. How can I do it? Pls help. Thanx in advance. astro mmi: What happens when you put hold on and display another image? Does it cover up the first one, so that all you see is the second one? "astro mmi&q...

Saving image ..??
Hai all, I want to draw text and graphics and save all these in a jpg or bmp image?? Do you have any idea??? I've read a tuotorial that uses the package javax.media... but it makes errors for me ( It doesnt find the package)....I've download the new version of java but this package and specifically the class javax.media.PlanarImage seems to be unavilable...Any help??? Thanx alot, Alshayeb.Rasha rasha_cs_99@hotmail.com wrote: > Hai all, > > I want to draw text and graphics and save all these in a jpg or bmp > image?? Do you have any idea??? > I've read a tuotor...

saving pdf as image
Hi, I am facing some issue when it comes to saving pdf as image. Actually I want to save a pdf into a tif file format, with option G4 compression, bitonal image. If the pdf is having embbeded image which is colourd, the output bitonal tif does not convert the colour image into botonal properly. Is there any way to controll the palleting happening inside ADOBE. Please Help scraut@gmail.com wrote: > Hi, > I am facing some issue when it comes to saving pdf as image. > Actually I want to save a pdf into a tif file format, with option G4 > compression, bitonal image. > > If...

saving ellipse to image
Hi guys, I'm trying to make an image in idl containing an ellipse that i can then do= a bunch of stuff to. I did a bit of digging and found the tvellipse comman= d...but that doesn't give me an image array (which i want), just puts the e= llipse in a graphics window. So I'm wondering, is there some way that I can= be sneaky and save this graphics window to a .tiff file or such so I can t= hen read in this awesome image array that I'm looking for? Or maybe I am go= ing about this in a very roundabout way and there is something simpler avai= lable? All the image save co...

Save images with colorbars
Hi, I have the following problem. I am working with images and trying to save my output with standard matlab colorbar on its right. For an image without colorbar I would just use imwrite(image,'A.png'), but the same image with colorbar I save using imagesc(image) colorbar image2 = imcapture(gcf, 'all', 150) % function from http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=13355 imwrite(image2,'B.png') This code works just fine, but it has an annoying problem of imagesc constantly opening windows. I am writing codes for batch proce...

saving image with plot
I have an image of a marine chart. I imported the image into matlab and figured out how to register pixel locations with latitude and longitude. Next I converted some GPS data from [latitude, longitude] pairs into pixel coordinates and plotted a track on top of the image. The only way I can figure out how to save the image with the track is to use the print command and save it to a jpeg. Does anyone know how to save the resulting image with the same resolution as the original image. Here is what I am doing: A = imread(filename, fmt); s=size(A); x=rand(s(1))*s(1);%for example ...

What can I do so that this image can be saved?
http://hesterloli.dnsalias.com/test/javascript_image.htm The image is the 100x100 px block. If we right-click in it and try to = save the image we cannot. Is it possible to say set a mime-type so that = it can be saved? Thanks. --=20 George Hester __________________________________ "George Hester" <hesterloli@hotmail.com> wrote in message news:%Rmad.292475\$bp1.261558@twister.nyroc.rr.com... http://hesterloli.dnsalias.com/test/javascript_image.htm The image is the 100x100 px block. If we right-click in it and try to save the image we cannot. Is it possible to say set a ...

Why no images in saved Safari pages?
When I save web pages to my HD, the images are missing when I open them. I see nothing in Preferences or elsewhere for specifying saving images. Ideas? PB G3/400; OS X 10.2.8; Safari 1.0.1 (v 85.6) Thanks, -- DaveC me@privacy.net This is an invalid return address Please reply in the news group DaveC wrote: > When I save web pages to my HD, the images are missing when I open them. > > I see nothing in Preferences or elsewhere for specifying saving images. > > Ideas? > > PB G3/400; OS X 10.2.8; Safari 1.0.1 (v 85.6) > > Thanks, Typically, Safari saves pag...

Saving an image from external site
Hi In Perl, how can I grab an image through its URL and save it on my server? Ex: save www.site.com/image.jpg onto a dir on my server (another.com) Im looking at setting a cronjob that through this perl script grabs this specific image once an hour and puts it on my server Thanks asdfq213rr23we@yahoo.com wrote: > Hi > > In Perl, how can I grab an image through its URL and save it on my > server? > > Ex: save www.site.com/image.jpg onto a dir on my server (another.com) > > Im looking at setting a cronjob that through this perl script grabs > this specific im...

saving data into a txt file
Hello I am trying to save the data into a data.txt file from a variable x which is 4000x1 vector The data needs to be saved in a txt file in the format 5.678 8.888 5.43 � save filename.txt x -ASCII �TABS is not putting them all in one column. I don�t know how to go abut doing this let alone use the fprintf if that�s what it takes. thanks Edo wrote: > Hello > > I am trying to save the data into a data.txt file from a variable x > which is 4000x1 vector > The data needs to be saved in a txt file in the format > 5.678 > 8.888 > 5.43 > � > > save filename....

save clipboard image server?
I have some javascript that will paste clipboards text to a web form. cool. but what i'd like to be able to to do save or send an image in my clipboard to the server somehow. Anyway for javascipt to create a binary stream of the clipboard and post that back tot he server? how about xml? Thanks for any help or infomation. On Jun 29, 3:12 am, jobs <j...@webdos.com> wrote: > I have some javascript that will paste clipboards text to a web form. > cool. but what i'd like to be able to to do save or send an image in > my clipboard to the server somehow. Anyway for javascipt...

saving and processing an image #2
Hi there ! I have got a IEEE 1394(firewire) camera and want to do a little image processing on pictures that I will take. this is my first code: imaqreset cam = imaqhwinfo('avtmatlabadaptor') cam.DeviceInfo(1).DeviceName cam.DeviceInfo(1).SupportedFormats vid=videoinput('avtmatlabadaptor',1,'F0M5_Mono8_640x480'); src=getselectedsource(vid); preview(vid) after this I got a video preview window , that's okay, but now I want to take a picture from this window and run my program for image processing on this new image, previously I have saved an image a...

saving an image #2 887022
Anyone, How would i write an image and then save it in "any folder and in any directory." My problem is i need to save a batch of images to an external hardrive because no room on PC. And i want it to be automated because I have hundreds of images so i really don't want to use the uiputfile for every image. I understand how the imwrite works but to then save the image is the part i'm having trouble with. So if i have save_image = imwrite(.....); how would i then save the save_image anywhere i want. Thank You for any help. Brad > save_image =3D imwrite(.....);...

How to save a figure as jpeg image
Hi All, I want to save my plots as jpeg (via Matlab code itself). After Plotting if i do 'hgsave' it saves my plot in the default MATLAB figure format (.fig), I want to save them as jpeg images. Thanks, Elan "Elangovan " <ea39@njit.edu> wrote in message <h4s68t\$n7b\$1@fred.mathworks.com>... > Hi All, > > I want to save my plots as jpeg (via Matlab code itself). > After Plotting if i do 'hgsave' it saves my plot in the default MATLAB figure format (.fig), I want to save them as jpeg images. > > Thanks, > Elan a hint: help p...

Saving Layers to Separate Images
Is there a quick way to save each layer in a PS file to a separate jpeg? Thank you A "amerdsp" <amerdsp@hotmail.com> wrote: > Is there a quick way to save each layer in a PS file to a separate > jpeg? Yes. Menu: File -> Automate -> Scripts -> Export Layers to Files You can choose a number of different formats, including JPEG ...

control click to save image
I used to be able to click once and hold down the mouse button to bring up the contextual menu which would allow me to save image as... for some reason this is gone and I must control-click and hold to do the same thing. Not the end of the world but aggravating. Does anyone know if there is a way to reset this? thanks In article <1164119851.001772.26820@h48g2000cwc.googlegroups.com>, formatc@gmail.com wrote: > I used to be able to click once and hold down the mouse button to bring > up the contextual menu which would allow me to save image as... > > for some reason thi...