Question

Image histogram code in python?

In this exercise you should write a Python function that computes

the histogram of an intensity (gray scale) image. Do not use specifific Python

functions for histogram computation (like hist or imhist).

Create a new function my_hist and start with the following lines:

function [h] = my_hist(im)

% H = MY_HIST(IM) computes the histogram for the intensity

% image IM (with values from 0 to 255) and returns a vector H

% with 256 dimensions

% get the image size: M = number of rows, N = number of columns

[M, N] = size(im);

% initilalize the histogram to zero

h = zeros(1,256);

% ... here goes your code ...

end % – do not forget the END!

To test your function, save the m-fifile and type at the prompt (omit the

comments):

% read image fifile

 I = imread(boat.tif);

% compute the histogram

 H = my_hist(I);

% display the result 


1 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 9 more requests to produce the answer.

1 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Image histogram code in python?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • In this exercise you should write a Python function that computes the histogram of an intensity (gray scale) image. Do not use specifific Python functions for histogram computation (like hist or imhist).

    Create a new function my_hist and start with the following lines:function [h] = my_hist(im)% H = MY_HIST(IM) computes the histogram for the intensity% image IM (with values from 0 to 255) and returns a vector H% with 256 dimensions% get the image size: M = number of rows, N = number of columns[M, N] = size(im);% initilalize the histogram to zeroh = zeros(1,256);% ... here goes your code ...end % – do not forget the END!To test your function, save...

  • Complete the MATLAB code - image convolution: - Implement image convolution in Matlab: -- Apply the following kernels and compare their images -- If output is less than zero, set it to zero -2 10 151...

    Complete the MATLAB code - image convolution: - Implement image convolution in Matlab: -- Apply the following kernels and compare their images -- If output is less than zero, set it to zero -2 10 151 0 10 0 1 0 clear % Read image A-int32 (imread ( [N, M]-size (A) % change unsigned to signed integer for matrix computation %-define convolution kernel L= 1; % half size of kernel % initialize kernel data = zeros (2*1+1,2*1+1) ; 88%%%%%%%%%88%88% build...

  • Please solve problem 4 and 5 using matlab and include the screenshot of the result ,...

    Please solve problem 4 and 5 using matlab and include the screenshot of the result , thank you Homework #8 Applied Programming, ENGR 10573 Spring 2018 Due Monday, Apr. 2 uploaded through TCU Online by 11:59 PM. Upload one script or function, named studentlastn ame-homework 8 ) n a single m- file that runs each problem. The homework problems should run sequentially showing I figure and or plots along with the proof that each problem works correctly. The single m-file...

  • the following python code edits BMP image file to negative but I need help with modifying...

    the following python code edits BMP image file to negative but I need help with modifying this code so it turns it the same BMP image file into a black and white instead of a negative. heres python code I have so far [pasted below] ## # This program processes a digital image by creating a negative of a BMP image. # from io import SEEK_CUR from sys import exit def main() : filename = input("Please enter the file name:...

  • When i run my python code i get the following error... and im not sure how...

    When i run my python code i get the following error... and im not sure how to fix the error, can someone help me? ____________________Hers my Code__________________ import face_recognition import cv2 # Get a reference to your webcam video_capture = cv2.VideoCapture(0) # Load a sample picture of yourself and learn how to recognize it. kyle_image = face_recognition.load_image_file("kyle.jpg") kyle_face_encoding = face_recognition.face_encodings(kyle_image)[0] # Load a second sample picture and learn how to recognize it. ##lauren_image = face_recognition.load_image_file("lauren.jpg") ##lauren_face_encoding = face_recognition.face_encodings(lauren_image)[0] # Load...

  • Please answer "b" only. %Example code function plotFS(m); %m = user provided number of terms desired in the Fou...

    Please answer "b" only. %Example code function plotFS(m); %m = user provided number of terms desired in the Fourier series; %this code computes the Fourier series of the function %f(x)=0, for -pi<= x <0, % =cos(x) for 0<= x <pi %generate the interval from -pi to pi with step size h; h = pi/100; xx1=[-pi:h:0]; xx2=[0:h:pi]; xx = [xx1, xx2]; %generate the given function f so that it can be graphed ff = [zeros(size(xx1)), cos(xx2)]; %compute the first partial sum...

  • This is a MATLAB Question. Below is my base code for a Fourier Series of a...

    This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • Python Project

    AssignmentBitmap files map three 8-bit (1-byte) color channels per pixel. A pixel is a light-emitting "dot" on your screen. Whenever you buy a new monitor, you will see the pixel configuration by its width and height, such as 1920 x 1080 (1080p) or 3840x2160 (4K). This tells us that we have 1080 rows (height), and each row has 1920 (width) pixels.The bitmap file format is fairly straight forward where we tell the file what our width and height are. When...

  • Please use Python def findSubstrings(s):     # Write your code here Consider a string, s = "abc"....

    Please use Python def findSubstrings(s):     # Write your code here Consider a string, s = "abc". An alphabetically-ordered sequence of substrings of s would be {"a", "ab", "abc", "b", "bc", "c"}. If the sequence is reduced to only those substrings that start with a vowel and end with a consonant, the result is {"ab", "abc"}. The alphabetically first element in this reduced list is "ab", and the alphabetically last element is "abc". As a reminder: • Vowels: a, e, i,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT