[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-685809-105":3,"detail-sidebar-cat-0-en-105":84,"doc-detail-685809-en":134,"doc-similar-685809":158},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":77,"head_meta":79,"extra_data":81,"updated_unix":83},105,"en","numpy-and-image-processing-primer-discussion-1","NumPy and Image Processing Primer Discussion - 1","","NumPy is introduced as a foundation for image handling by treating images as arrays. The material focuses on core array properties such as shape and dtype, including how dtype casting truncates or overflows numeric values (e.g., float-to-uint8 and overflow behavior). It then covers practical array composition and manipulation: stacking vs. concatenation, slicing differences that preserve dimensions, boolean indexing for conditional edits, and managing singleton dimensions with squeeze and expand_dims. Finally, it connects array conventions to pixel formats and channel ordering.",{"@graph":14,"@context":76},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/numpy-and-image-processing-primer-discussion-1/685809/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/numpy-and-image-processing-primer-discussion-1/685809.png","ImageObject",300,407,{"name":42,"@type":43},"Aldword","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-18","2026-11-07",true,{"@type":52,"interactionType":53,"userInteractionCount":33},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68,72],{"name":59,"@type":60,"acceptedAnswer":61},"Why are shape and dtype considered the two most important array properties?","Question",{"text":62,"@type":63},"Shape determines the array’s axes and sizes, while dtype determines the data type and value interpretation. Confusing dimension vs. shape can lead to incorrect indexing and processing.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"What happens when float values are cast to uint8 in NumPy?",{"text":67,"@type":63},"Casting float64 values to uint8 truncates the float (e.g., 255.2 becomes 255). Floats between 0 and 1 become 0, which can introduce hidden bugs if unhandled.",{"name":69,"@type":60,"acceptedAnswer":70},"How do np.stack and np.concatenate differ when combining images?",{"text":71,"@type":63},"np.stack adds a new dimension at the specified axis, preserving the original arrays as stacked elements. np.concatenate joins along an existing axis, effectively combining the arrays by extending that axis (e.g., doubling height or width).",{"name":73,"@type":60,"acceptedAnswer":74},"What is channel order confusion in image arrays, and how can it be corrected?",{"text":75,"@type":63},"Some libraries use BGR ordering while others expect RGB, which can make images look incorrect when visualized. The document shows converting BGR to RGB using np.flip and switching channel order using transpose.","https://schema.org",{"og:url":32,"og:type":78,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":80,"canonical":32},"index,follow",{"doc_id":82,"site_id":7},685809,1794018719,{"code":4,"msg":85,"data":86},"success",[87,91,95,99,104,108,113,118,123,126,130],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":96,"show_sort_weight":97,"slug":98},"Exam",70,"exam",{"id":100,"doc_module":4,"doc_module_name":25,"category_name":101,"show_sort_weight":102,"slug":103},5,"Comic",60,"comic",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":106,"slug":107},6,50,"technology",{"id":109,"doc_module":4,"doc_module_name":25,"category_name":110,"show_sort_weight":111,"slug":112},7,"Healthcare",40,"healthcare",{"id":114,"doc_module":4,"doc_module_name":25,"category_name":115,"show_sort_weight":116,"slug":117},8,"Research & Report",30,"research-report",{"id":119,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":121,"slug":122},9,"Religion & Spirituality",20,"religion-spirituality",{"id":121,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":121,"slug":125},"World Cup","world-cup",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":127,"slug":129},10,"Lifestyle","lifestyle",{"id":131,"doc_module":4,"doc_module_name":25,"category_name":132,"show_sort_weight":100,"slug":133},19,"General","general",{"code":4,"msg":85,"data":135},{"doc_id":82,"user_id":136,"nickname":42,"user_avatar":137,"doc_module":4,"category_id":105,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":138,"file_id":139,"file_url":140,"file_type":141,"file_size":142,"view_count":33,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":143,"language":144,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":145,"faqs":146,"seo_title":147,"seo_description":12,"update_tm":83,"read_time":148,"preview_page_count":26,"preview_urls":149},2336478940917,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","NumPy and Image Processing Primer Discussion \\#1  \nWritten by:  \nJustin, Chung Min  \nLearning Objectives  \nToday, we will learn that images are just arrays – so it’s time to learn how to use NumPy. You might be rusty with NumPy from that class you took years ago, or it’s the first time you’ve really used it seriously. This time, ideally, using NumPy should start to feel like second nature.  \nHopefully, by the end of the hour, you will feel comfortable with handling images in the form of arrays, and get to practice some practical coding knowledge for upcoming CS180/280A projects. If you feel comfortable with NumPy, feel free to look at the challenge questions uploaded online!  \nLogistics  \n1. Project 1 is out! due Fri. Sep. 15, 11:59PM.  \n1 Warmup!  \n1.1 shape and dtype  \nThe two most important properties of arrays are their shape and dtype. A common terminology mixup is in referring to the mathematical concept of dimension, which refers to how big a given axis is, and the shape which refers to how many axes and how big each one is of an array.x2  \nProblem 1.1: What is the shape of a 3x3 matrix in NumPy? A 3-dimension row vector? Column vector?  \nA 3x3 matrix has shape (3, 3) . A 3-element row vector has shape (1, 3) . A 3-element column vector has shape (3, 1) .  \nWhat are the shape, dtype, values of the following one-liners:  \n(a) np.full((10, 10, 3), 255.2)  \nShape: (10, 10, 3), dtype: float64, values: all 255.2  \n(b) np.full((10, 10, 3), 255.2) .astype(np.uint8)  \nShape: (10, 10, 3), dtype: uint8, values: all 255 . The float 255.2 gets truncated to 255 when cast to uint8 .  \n(c) np.full((10, 10, 3), 256.0) .astype(np.uint8)  \nShape: (10, 10, 3), dtype: uint8, values: all 0 . Since uint8 range is 0-255, 256 overflows and wraps to 0 .  \n(d) np .array([0 . 1, 0.2, 0.3]) .astype(np.uint8)  \nShape: (3,), dtype: uint8, values: [0, 0, 0] . Floats between 0 and 1 get truncated to 0 when cast to uint8 .  \nNote: casting from float to uint8 is the source of lots of hidden project bugs, be careful!  \n1.2 stack vs concatenate  \nJoining arrays together is usually done with these helper functions, let’s remind ourselves how they work.  \nProblem 1.2: Suppose I have img1 and img2 which are both shape (100,100,3) . What shape do the following evaluate to?  \n(a) np.stack([img1, img2], axis=0)  \n(2, 100, 100, 3) -Creates a new dimension at axis 0, stacking the images.  \n(b) np.stack([img1, img2], axis=1)  \n(100, 2, 100, 3) -Creates a new dimension at axis 1, between height and width.  \n(c) np.concatenate([img1, img2], axis=0)  \n(200, 100, 3) -Joins along axis 0, doubling the height (stacking vertically) .  \n(d) np.concatenate([img1, img2], axis=1)  \n(100, 200, 3) -Joins along axis 1, doubling the width (placing side by side) .  \n1.3 Slicing  \nSlicing is how we obtain smaller chunks of arrays from a larger one, including for manipulating their values. Slicing can also be done with indices or mask arrays for logical operations!  \nProblem 1.3: What’s the difference between arr[0] and arr[0:1] for a 2D array?  \narr[0] returns a 1D array (the first row), while arr[0:1] returns a 2D array with shape (1, width) -preserves the row dimension.  \nProblem 1.4: How would you set all elements in the first row of a 2D array to zero?  \narr[0, :] = 0 or arr[0] = 0  \nProblem 1.5: Given a floating point array arr, how do you set all values above 1 to exactly 1.0?  \narr[arr > 1] = 1 .0-Uses boolean indexing to select and modify elements.  \n1.4 Singleton dimensions  \nOne confusing aspect of arrays is that data can have dimensions of size 1 (for example depth images!), which are very important for downstream ops.  \nProblem 1.6: What’s the shape of np.array([1,2,3])? np.array([[1],[2],[3]])?  \nnp.array([1,2,3]) has shape (3,) - [1D array.](1D array. np.array)[ np.array](1D array. np.array)([[1],[2],[3]]) has shape (3,1) - 2D column vector.  \nProblem 1.7: What happens when you use np.squeeze() on an array of shape (1,5,1,3)?  \nReturns shape (5,3) -removes all singlet","cbCaij0FBTbghA7D","https://ap.wps.com/l/cbCaij0FBTbghA7D","pdf",204053,14,"English","# Learning Objectives\n# Logistics\n# Warmup\n## shape and dtype\n## stack vs concatenate\n## Slicing\n## Singleton dimensions\n# Pixels\n## Convention Confusion","[{\"question\":\"Why are shape and dtype considered the two most important array properties?\",\"answer\":\"Shape determines the array’s axes and sizes, while dtype determines the data type and value interpretation. Confusing dimension vs. shape can lead to incorrect indexing and processing.\"},{\"question\":\"What happens when float values are cast to uint8 in NumPy?\",\"answer\":\"Casting float64 values to uint8 truncates the float (e.g., 255.2 becomes 255). Floats between 0 and 1 become 0, which can introduce hidden bugs if unhandled.\"},{\"question\":\"How do np.stack and np.concatenate differ when combining images?\",\"answer\":\"np.stack adds a new dimension at the specified axis, preserving the original arrays as stacked elements. np.concatenate joins along an existing axis, effectively combining the arrays by extending that axis (e.g., doubling height or width).\"},{\"question\":\"What is channel order confusion in image arrays, and how can it be corrected?\",\"answer\":\"Some libraries use BGR ordering while others expect RGB, which can make images look incorrect when visualized. The document shows converting BGR to RGB using np.flip and switching channel order using transpose.\"}]","NumPy and Image Processing Primer Discussion - 1 | PDF",35,[150,154],{"page_no":22,"url":151,"width":152,"height":153},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/174b37e446f9a22ec50cf86857d8f905.webp",983,1272,{"page_no":26,"url":155,"width":156,"height":157},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/697a712f00289ccd190a57bf10599840.webp",982,1270,{"list":159,"token":11},[160,166,171,177,183,190,196,202,208,215],{"doc_id":161,"doc_title":162,"file_type":141,"home_preview_img_url":163,"slug":164,"view_count":100,"category_name":29,"create_tm":165},685805,"Numpy - Array - Chapter 11 - Informatics Practices","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000213217/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=NmHHwL0Tg6ObPlCBRHcLGYJ6WEo%3D","numpy-array-chapter-11-informatics-practices",1794018711,{"doc_id":167,"doc_title":168,"file_type":141,"home_preview_img_url":169,"slug":170,"view_count":114,"category_name":29,"create_tm":83},685810,"Lecture 3 - NumPy basics - Arrays and Vectorized Computation","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000213289/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=qz4VExOicVTWKvUATxe3K166%2B44%3D","lecture-3-numpy-basics-arrays-and-vectorized-computation",{"doc_id":172,"doc_title":173,"file_type":141,"home_preview_img_url":174,"slug":175,"view_count":105,"category_name":29,"create_tm":176},685790,"NumPy and SciPy Tutorial - Installation and Array Fundamentals","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000209033/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=aMdfjFEhAukv7%2FeVgF%2Bd3LwAlvY%3D","numpy-and-scipy-tutorial-installation-and-array-fundamentals",1794018485,{"doc_id":178,"doc_title":179,"file_type":141,"home_preview_img_url":180,"slug":181,"view_count":100,"category_name":29,"create_tm":182},670915,"Python Cheat Sheet - Quick Reference","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988353347/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=olUKWz3WHxsQQcM6Hsybg9ty5jQ%3D","python-cheat-sheet-quick-reference-670915",1793572692,{"doc_id":184,"doc_title":185,"file_type":141,"home_preview_img_url":186,"slug":187,"view_count":188,"category_name":29,"create_tm":189},423014,"THE JAVA LANGUAGE CHEAT SHEET - quick reference","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229922611453/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=yGKTRXL8d87EfZ6NuJIBmzfaBe8%3D","the-java-language-cheat-sheet-quick-reference",13,1790629749,{"doc_id":191,"doc_title":192,"file_type":141,"home_preview_img_url":193,"slug":194,"view_count":109,"category_name":29,"create_tm":195},469298,"Finding My CRS - A Systematic Way of Identifying CRSs","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229926544534/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=zZaOxX%2Fh%2BU4p%2BIUUPIS4Mk2Qw5E%3D","finding-my-crs-a-systematic-way-of-identifying-crss",1790775391,{"doc_id":197,"doc_title":198,"file_type":141,"home_preview_img_url":199,"slug":200,"view_count":33,"category_name":29,"create_tm":201},699485,"Camera Production Guide - Blackmagic URSA Cine 17K 65","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230011036765/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=oDeZzJowKpubEyHSTDbUWt4ralI%3D","camera-production-guide-blackmagic-ursa-cine-17k-65",1794469535,{"doc_id":203,"doc_title":204,"file_type":141,"home_preview_img_url":205,"slug":206,"view_count":100,"category_name":29,"create_tm":207},700552,"KLT-MFA77-IMX219 V2.0 - Fixed Focus Camera Module - Specifications","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230011567722/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=5TBzcqIG6uXw82tK%2BnOV%2F9a3e20%3D","klt-mfa77-imx219-v20-fixed-focus-camera-module-specifications",1794519312,{"doc_id":209,"doc_title":210,"file_type":141,"home_preview_img_url":211,"slug":212,"view_count":213,"category_name":29,"create_tm":214},115355,"Claude AI Bible - The Complete Guide to Mastering Claude, Claude Code, Claude Cowork, MCP, AI Agents, Automation & Advanced Prompting","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229831893665/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=fvVeGWoP87YwuQ8VttTVWdIY1J8%3D","claude-ai-bible-the-complete-guide-to-mastering-claude-claude-code-claude-cowork-mcp-ai-agents-automation-advanced-prompting",910,1785472614,{"doc_id":216,"doc_title":217,"file_type":141,"home_preview_img_url":218,"slug":219,"view_count":220,"category_name":29,"create_tm":221},185,"XNX Universal Transmitter Installation Manual (Complete Guide) [Honeywell Official]","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229693710157/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796108039&Signature=IgofXAp99hRkDfL2RAF1TnlSUUU%3D","xnx-universal-transmitter-installation-manual",854,1776135954]