Im2uint8,im2wb,mat2gray and other image data type conversion functions

Source: Internet
Author: User

%%%%%%%%%%%%%%% Data Type%%%%%%%%%%%%%%%%%%%%type conversion Clear Clca=3.14%default is Doublewhosa=uint8 (a)%type conversion, fractional part rounding a=[1.1,2.1,3.1;4.1,5.1,6.5;7.6,8.7,9.7]a=uint8 (A)%As with matrices, you can%%im2uint8 Image Clc;cleara= [-0.5 0.5     0.75 1.5] G1= Im2uint8 (A)%the minimum value of F1 is 0 and the maximum value is 255F2= Uint8 (A)%type conversion rounding, negative number all returned to zero%%Im2doubleclccleara=uint8 ([0 127 255; -  to  the;1 2 3]) I=im2double (A) a zero-percent input is a matrix of uint8, and the output is from [0,255To0.0,1.0]a=[0 127 255; -  to  the;1 2 3]i=im2double (A)%the input is a doubel matrix and is output as-is. %%IM2BW Gray image becomes a two value image Clccleara=[0 1 0.1;0.4Pi0.5;0.51 0.41 0.39]BW= IM2BW (A)%default to 0.5, greater than logic 1, less than logic 0BW= IM2BW (A,0.4)   %with 0.4 verdict, the output is the logical matrix BW= IM2BW (A,0.5) BW= IM2BW (A,1)%%Str2numclcclearstr2num ('123') Str2Num ('123 456') Str2Num (['1 2';'3 4'])%%mat2grayclose All;clear;clca=[0 1-0.1;0.4Pi0.5;0.51 0.41 0.39]k= Mat2gray (A)% is mapped from [Min, Max] to [0,1]i= Imread ('Rice.png'); J= Filter2 (Fspecial ('Sobel'), I); K=Mat2gray (j); Imshow (I), figure, Imshow (j); Figure,imshow (K)

Im2uint8,im2wb,mat2gray and other image data type conversion functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.