How to format a document in Notepad++?

What is code to convert an RGB image to binary image , and then save that image in form of matrix in notepad? one more question: code to convert binary matrix in notepad to Binary image format? Please reply fast

  • I have an image(PNG, JPEG, etc) in the RGB format. However, I would like to create a routine for loading into MATLAB saving it in a text file which can be viewing in a notepad.

  • Answer:

    how can we convert random lines detected in m...

Muhammad Waqar at Quora Visit the source

Was this solution helpful to you?

Other answers

The following would be one of the alternatives to 's answer for saving the image, otherwise his method works well too. The resulting answer is logical, but has a double value which is the reason for the formatting in the text file. Writing a logical value into a text in ASCII format is not supported (http://www.mathworks.com/help/matlab/ref/save.html) . You can type the following in MATLAB: %Read the image im = imread('peppers.png'); %Conversion im = double(im2bw(im)); %Write to file save('peppers.txt','-ascii','im')

Lokesh Amarnath

Here is a matlab code that does it:- %Read the image im = imread('a.jpg'); %Convert it to bw im = im2bw(im); %Open file stream fid = fopen('abc.txt','w'); [row col] = size(i); for x=1:row for y=1:col fprintf(fid,'%d ',i(x,y)); end fprintf(fid,'\n'); end fclose(fid); Hint: Use your file names instead of  'a.jpg' and 'abc.txt' also 'a.jpg' should be in the same folder as this script. Update: This will work with other image formats too.

Anonymous

%%%%%code for rgb to binary image I = imread('imagename.jpg/png'); %read image level=0.5; %  level value 1 (white) and 0 (black) BW = im2bw(I, level); %converts the truecolor image RGB to a binary image. imshow(I), figure, imshow(BW) %%%%%%%%%%% %%save as text file in form of matrix fid = fopen('myoutput.txt', 'w'); fprintf(fid, '%f', BW); fclose(fid);

Amit Singh

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.