SlideShare a Scribd company logo
1 of 7
function [X,map,out3]=bmpread(filename);

%BMPREAD Read a BMP (Microsoft Windows Bitmap) file from disk.

%      [X,MAP]=BMPREAD('filename') reads the file 'filename' and

%      returns the indexed image X and associated colormap

%      MAP. If no extension is given for the filename, the

%      extension '.bmp' is assumed.

%      [R,G,B]=BMPREAD('filename') reads the 24-bit BMP file

%      from the file 'filename'.

%      BPP=BMPREAD('filename') returns the number of bits per

%      pixel in the BMP file.

%

%      BMPREAD does not read 1-bit or compressed BMP files.

%

%      See also: BMPWRITE, GIFREAD, HDFREAD, PCXREAD, TIFFREAD,

%                XWDREAD.



%      Mounil Patel 3/10/94

%      Revised Steve Eddins February 9, 1995

%      Copyright (c) 1994 by The MathWorks, Inc.

%      $Revision: 1.14 $    $Date: 1996/06/14 12:39:07 $




if (nargin~=1)

       error('Requires a filename as an argument.');

end;



if (isstr(filename)~=1)

       error('Requires a string filename as an argument.');

end;



if (isempty(findstr(filename,'.'))==1)

       filename=[filename,'.bmp'];
end;



fid=fopen(filename,'rb','l');

if (fid==-1)

       error(['Error opening ',filename,' for input.']);

end;



bfType=fread(fid,2,'uchar');

if (bfType~=[66;77])

       fclose(fid);

       error('Not a BMP file.');

end;



bfSize=fread(fid,1,'uint');

bfReserved1=fread(fid,1,'ushort');

bfReserved2=fread(fid,1,'ushort');

bfOffBytes=fread(fid,1,'uint');



biSize=fread(fid,1,'uint');

if (biSize~=40)

       fclose(fid);

       error('Not a MS Windows Device Independent Bitmap BMP file.');

end;



biWidth=fread(fid,1,'uint');

biHeight=fread(fid,1,'uint');

biPlanes=fread(fid,1,'ushort');

biBitCount=fread(fid,1,'ushort');

if (biBitCount == 1)

  error('BMPREAD does not read 1-bit BMP files.');

end

biCompression=fread(fid,1,'uint');
if biCompression~=0

        error('Can''t load compressed format bitmaps.');

end;

biSizeImage=fread(fid,1,'uint');

biXPels=fread(fid,1,'uint');

biYPels=fread(fid,1,'uint');

biClrUsed=fread(fid,1,'uint');

biClrImportant=fread(fid,1,'uint');



if (nargout <= 1)

  X = biBitCount;

  map = [];

  fclose(fid);

  return;

end



if ((nargout == 2) & (biBitCount == 24))

  error('Three output arguments required for 24-bit BMP file.');

end



if ((nargout == 3) & (biBitCount < 24))

  error('Only two arguments needed for 4- and 8-bit BMP files.');

end



if (biBitCount == 24)

  if (rem(biWidth,4)~=0)

      XSize=biWidth+(4-rem(biWidth,4));

  else

      XSize=biWidth;

  end

  YSize=biHeight;

  Size=XSize*YSize;
fseek(fid, bfOffBytes, 'bof');

  X=fread(fid,Size*3,'uchar');

  out3 = rot90(reshape(X(1:3:length(X)), XSize, YSize)) * (1/255);

  map = rot90(reshape(X(2:3:length(X)), XSize, YSize)) * (1/255);

  X = rot90(reshape(X(3:3:length(X)), XSize, YSize)) * (1/255);

  if (rem(biWidth,4)~=0)

      X=X(:,1:biWidth);

      map = map(:,1:biWidth);

      out3 = out3(:,1:biWidth);

  end;



  fclose(fid);

  return;

end



if (biClrUsed==0)

       nColors=2.^biBitCount;

else

       nColors=biClrUsed;

end;



% load color map now

if (biClrUsed>256)

       map=[];      % 24-bit images have no colormap

else

       map=fread(fid,4*nColors,'uchar');

       map=reshape(map,4,nColors);

       map=map';

       map=map(:,1:3);

       map=fliplr(map);

end;
map=map./255;



% read in 8-bit image data

if (biBitCount==8)

       if (rem(biWidth,4)~=0)

              XSize=biWidth+(4-rem(biWidth,4));

       else

              XSize=biWidth;

       end

       YSize=biHeight;

       Size=XSize*YSize;



       fseek(fid, bfOffBytes, 'bof');

       X=fread(fid,Size,'uchar');

       X=reshape(X,XSize,YSize);

       X=rot90(X);

       X=X+1;

       if (rem(biWidth,4)~=0)

              X=X(:,1:biWidth);

       end;

end;



if (biBitCount==4)

       XSize=ceil(biWidth/2);

       if (rem(XSize,4)~=0)

              XSize=XSize+rem(XSize,4);

       end;

       YSize=biHeight;

       Size=XSize*YSize;

       fseek(fid, bfOffBytes, 'bof');

       X=fread(fid,Size,'uchar');
X=reshape(X,XSize,YSize);

       X=X';

       loX=X;



       index=loX>127;

       loX(index)=loX(index)-128;

       index=loX>63;

       loX(index)=loX(index)-64;

       index=loX>31;

       loX(index)=loX(index)-32;

       index=loX>15;

       loX(index)=loX(index)-16;



       X=X-loX;

       X=X./16;

       [m,n]=size(X);

       X(:,1:2:(n*2))=X;

       X(:,2:2:(n*2))=loX;

       X=flipud(X);

       X=X+1;

end;



cmax=max(max(X));

map=map(1:cmax,:);



fclose(fid);
X=reshape(X,XSize,YSize);

       X=X';

       loX=X;



       index=loX>127;

       loX(index)=loX(index)-128;

       index=loX>63;

       loX(index)=loX(index)-64;

       index=loX>31;

       loX(index)=loX(index)-32;

       index=loX>15;

       loX(index)=loX(index)-16;



       X=X-loX;

       X=X./16;

       [m,n]=size(X);

       X(:,1:2:(n*2))=X;

       X(:,2:2:(n*2))=loX;

       X=flipud(X);

       X=X+1;

end;



cmax=max(max(X));

map=map(1:cmax,:);



fclose(fid);

More Related Content

What's hot

Assignment3 solution 3rd_edition
Assignment3 solution 3rd_editionAssignment3 solution 3rd_edition
Assignment3 solution 3rd_editionMysore
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..Dr. Volkan OBAN
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
 
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...Mozaic Works
 
Gate level minimization (1st update)
Gate level minimization (1st update)Gate level minimization (1st update)
Gate level minimization (1st update)Aravir Rose
 
Interpolation graph c++
Interpolation graph c++Interpolation graph c++
Interpolation graph c++rpiitcbme
 

What's hot (15)

Assignment3 solution 3rd_edition
Assignment3 solution 3rd_editionAssignment3 solution 3rd_edition
Assignment3 solution 3rd_edition
 
Geohex at Off4g2009
Geohex at Off4g2009Geohex at Off4g2009
Geohex at Off4g2009
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
 
Basic Calculus in R.
Basic Calculus in R. Basic Calculus in R.
Basic Calculus in R.
 
Mosaic plot in R.
Mosaic plot in R.Mosaic plot in R.
Mosaic plot in R.
 
Mate tarea - 3º
Mate   tarea - 3ºMate   tarea - 3º
Mate tarea - 3º
 
Mate tarea - 2º
Mate   tarea - 2ºMate   tarea - 2º
Mate tarea - 2º
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
Hw #2
Hw #2Hw #2
Hw #2
 
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
 
Rkf
RkfRkf
Rkf
 
8.1 algebra
8.1 algebra8.1 algebra
8.1 algebra
 
Gate level minimization (1st update)
Gate level minimization (1st update)Gate level minimization (1st update)
Gate level minimization (1st update)
 
Calc 7.3b
Calc 7.3bCalc 7.3b
Calc 7.3b
 
Interpolation graph c++
Interpolation graph c++Interpolation graph c++
Interpolation graph c++
 

Viewers also liked

ppcHIT Introduction
ppcHIT IntroductionppcHIT Introduction
ppcHIT Introductionsortivo
 
Istilah, pengertian & cakupan ideologi
Istilah, pengertian & cakupan ideologiIstilah, pengertian & cakupan ideologi
Istilah, pengertian & cakupan ideologiakucintaalloh
 
Sexual maturation
Sexual maturationSexual maturation
Sexual maturationDaniel_OF
 
Panduan pelayanan-kerohanian-baru
Panduan pelayanan-kerohanian-baruPanduan pelayanan-kerohanian-baru
Panduan pelayanan-kerohanian-baruAmat Brandals
 
Why are Good Theorys Good- Review
Why are Good Theorys Good- ReviewWhy are Good Theorys Good- Review
Why are Good Theorys Good- ReviewSinu G S
 
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]Øyvind Jacobsen
 
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]Øyvind Jacobsen
 

Viewers also liked (15)

Kajian bahan ajar 1
Kajian bahan ajar 1Kajian bahan ajar 1
Kajian bahan ajar 1
 
ppcHIT Introduction
ppcHIT IntroductionppcHIT Introduction
ppcHIT Introduction
 
Kajian bahan ajar 1
Kajian bahan ajar 1Kajian bahan ajar 1
Kajian bahan ajar 1
 
Images of Life
Images of LifeImages of Life
Images of Life
 
2n1grup3
2n1grup32n1grup3
2n1grup3
 
Handout guru
Handout guruHandout guru
Handout guru
 
Graffiti en america
Graffiti en americaGraffiti en america
Graffiti en america
 
Istilah, pengertian & cakupan ideologi
Istilah, pengertian & cakupan ideologiIstilah, pengertian & cakupan ideologi
Istilah, pengertian & cakupan ideologi
 
Sexual maturation
Sexual maturationSexual maturation
Sexual maturation
 
Solr
SolrSolr
Solr
 
Panduan pelayanan-kerohanian-baru
Panduan pelayanan-kerohanian-baruPanduan pelayanan-kerohanian-baru
Panduan pelayanan-kerohanian-baru
 
Why are Good Theorys Good- Review
Why are Good Theorys Good- ReviewWhy are Good Theorys Good- Review
Why are Good Theorys Good- Review
 
Ppt komunikasi
Ppt komunikasiPpt komunikasi
Ppt komunikasi
 
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
 
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
Om 3 år, driver alle med Inbound markedsføring og salg? [Inbound Marketing]
 

Similar to Bmpread

Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphaelPippi Labradoodle
 
Company_X_Data_Analyst_Challenge
Company_X_Data_Analyst_ChallengeCompany_X_Data_Analyst_Challenge
Company_X_Data_Analyst_ChallengeMark Yashar
 
Following are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdfFollowing are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdfanithareadymade
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional creditRaihan Bin-Mofidul
 
Ans#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdf
Ans#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdfAns#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdf
Ans#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdfaryan9007
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
tensorflow/keras model coding tutorial 勉強会
tensorflow/keras model coding tutorial 勉強会tensorflow/keras model coding tutorial 勉強会
tensorflow/keras model coding tutorial 勉強会RyoyaKatafuchi
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineersvarun arora
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graphkinan keshkeh
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsKandarp Tiwari
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programsAmit Kapoor
 
include.docx
include.docxinclude.docx
include.docxNhiPtaa
 

Similar to Bmpread (20)

Creating masterpieces with raphael
Creating masterpieces with raphaelCreating masterpieces with raphael
Creating masterpieces with raphael
 
Company_X_Data_Analyst_Challenge
Company_X_Data_Analyst_ChallengeCompany_X_Data_Analyst_Challenge
Company_X_Data_Analyst_Challenge
 
Cquestions
Cquestions Cquestions
Cquestions
 
Following are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdfFollowing are the changes mentioned in bold in order to obtain the r.pdf
Following are the changes mentioned in bold in order to obtain the r.pdf
 
Computer hw1
Computer hw1Computer hw1
Computer hw1
 
Ee 3122 numerical methods and statistics sessional credit
Ee 3122 numerical methods and statistics sessional  creditEe 3122 numerical methods and statistics sessional  credit
Ee 3122 numerical methods and statistics sessional credit
 
Ans#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdf
Ans#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdfAns#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdf
Ans#define WM_CAP_START 0x0400 #define WM_CAP_DRIVER_CONNECT (W.pdf
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
tensorflow/keras model coding tutorial 勉強会
tensorflow/keras model coding tutorial 勉強会tensorflow/keras model coding tutorial 勉強会
tensorflow/keras model coding tutorial 勉強会
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
 
2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph2Bytesprog2 course_2014_c9_graph
2Bytesprog2 course_2014_c9_graph
 
My bitmap
My bitmapMy bitmap
My bitmap
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
include.docx
include.docxinclude.docx
include.docx
 
C questions
C questionsC questions
C questions
 
Otsu
OtsuOtsu
Otsu
 
R meets Hadoop
R meets HadoopR meets Hadoop
R meets Hadoop
 
Save game function
Save game functionSave game function
Save game function
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

Bmpread

  • 1. function [X,map,out3]=bmpread(filename); %BMPREAD Read a BMP (Microsoft Windows Bitmap) file from disk. % [X,MAP]=BMPREAD('filename') reads the file 'filename' and % returns the indexed image X and associated colormap % MAP. If no extension is given for the filename, the % extension '.bmp' is assumed. % [R,G,B]=BMPREAD('filename') reads the 24-bit BMP file % from the file 'filename'. % BPP=BMPREAD('filename') returns the number of bits per % pixel in the BMP file. % % BMPREAD does not read 1-bit or compressed BMP files. % % See also: BMPWRITE, GIFREAD, HDFREAD, PCXREAD, TIFFREAD, % XWDREAD. % Mounil Patel 3/10/94 % Revised Steve Eddins February 9, 1995 % Copyright (c) 1994 by The MathWorks, Inc. % $Revision: 1.14 $ $Date: 1996/06/14 12:39:07 $ if (nargin~=1) error('Requires a filename as an argument.'); end; if (isstr(filename)~=1) error('Requires a string filename as an argument.'); end; if (isempty(findstr(filename,'.'))==1) filename=[filename,'.bmp'];
  • 2. end; fid=fopen(filename,'rb','l'); if (fid==-1) error(['Error opening ',filename,' for input.']); end; bfType=fread(fid,2,'uchar'); if (bfType~=[66;77]) fclose(fid); error('Not a BMP file.'); end; bfSize=fread(fid,1,'uint'); bfReserved1=fread(fid,1,'ushort'); bfReserved2=fread(fid,1,'ushort'); bfOffBytes=fread(fid,1,'uint'); biSize=fread(fid,1,'uint'); if (biSize~=40) fclose(fid); error('Not a MS Windows Device Independent Bitmap BMP file.'); end; biWidth=fread(fid,1,'uint'); biHeight=fread(fid,1,'uint'); biPlanes=fread(fid,1,'ushort'); biBitCount=fread(fid,1,'ushort'); if (biBitCount == 1) error('BMPREAD does not read 1-bit BMP files.'); end biCompression=fread(fid,1,'uint');
  • 3. if biCompression~=0 error('Can''t load compressed format bitmaps.'); end; biSizeImage=fread(fid,1,'uint'); biXPels=fread(fid,1,'uint'); biYPels=fread(fid,1,'uint'); biClrUsed=fread(fid,1,'uint'); biClrImportant=fread(fid,1,'uint'); if (nargout <= 1) X = biBitCount; map = []; fclose(fid); return; end if ((nargout == 2) & (biBitCount == 24)) error('Three output arguments required for 24-bit BMP file.'); end if ((nargout == 3) & (biBitCount < 24)) error('Only two arguments needed for 4- and 8-bit BMP files.'); end if (biBitCount == 24) if (rem(biWidth,4)~=0) XSize=biWidth+(4-rem(biWidth,4)); else XSize=biWidth; end YSize=biHeight; Size=XSize*YSize;
  • 4. fseek(fid, bfOffBytes, 'bof'); X=fread(fid,Size*3,'uchar'); out3 = rot90(reshape(X(1:3:length(X)), XSize, YSize)) * (1/255); map = rot90(reshape(X(2:3:length(X)), XSize, YSize)) * (1/255); X = rot90(reshape(X(3:3:length(X)), XSize, YSize)) * (1/255); if (rem(biWidth,4)~=0) X=X(:,1:biWidth); map = map(:,1:biWidth); out3 = out3(:,1:biWidth); end; fclose(fid); return; end if (biClrUsed==0) nColors=2.^biBitCount; else nColors=biClrUsed; end; % load color map now if (biClrUsed>256) map=[]; % 24-bit images have no colormap else map=fread(fid,4*nColors,'uchar'); map=reshape(map,4,nColors); map=map'; map=map(:,1:3); map=fliplr(map); end;
  • 5. map=map./255; % read in 8-bit image data if (biBitCount==8) if (rem(biWidth,4)~=0) XSize=biWidth+(4-rem(biWidth,4)); else XSize=biWidth; end YSize=biHeight; Size=XSize*YSize; fseek(fid, bfOffBytes, 'bof'); X=fread(fid,Size,'uchar'); X=reshape(X,XSize,YSize); X=rot90(X); X=X+1; if (rem(biWidth,4)~=0) X=X(:,1:biWidth); end; end; if (biBitCount==4) XSize=ceil(biWidth/2); if (rem(XSize,4)~=0) XSize=XSize+rem(XSize,4); end; YSize=biHeight; Size=XSize*YSize; fseek(fid, bfOffBytes, 'bof'); X=fread(fid,Size,'uchar');
  • 6. X=reshape(X,XSize,YSize); X=X'; loX=X; index=loX>127; loX(index)=loX(index)-128; index=loX>63; loX(index)=loX(index)-64; index=loX>31; loX(index)=loX(index)-32; index=loX>15; loX(index)=loX(index)-16; X=X-loX; X=X./16; [m,n]=size(X); X(:,1:2:(n*2))=X; X(:,2:2:(n*2))=loX; X=flipud(X); X=X+1; end; cmax=max(max(X)); map=map(1:cmax,:); fclose(fid);
  • 7. X=reshape(X,XSize,YSize); X=X'; loX=X; index=loX>127; loX(index)=loX(index)-128; index=loX>63; loX(index)=loX(index)-64; index=loX>31; loX(index)=loX(index)-32; index=loX>15; loX(index)=loX(index)-16; X=X-loX; X=X./16; [m,n]=size(X); X(:,1:2:(n*2))=X; X(:,2:2:(n*2))=loX; X=flipud(X); X=X+1; end; cmax=max(max(X)); map=map(1:cmax,:); fclose(fid);