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:...

  • % BACKGROUND:Image processing is the generation of a new image from one or more existing images....

    % BACKGROUND:Image processing is the generation of a new image from one or more existing images. % MATLAB makes it easy to work with images by providing some basic functions % that allow you to read and write images in standard image -file formats, such as JPEG % Locate the attached photo of a blue bird stored in JPEG format, bbird.jpg (must be on same folder as script). % Fill in the ? in the code with correct values to...

  • Please write a code in python! Define and test a function named posterize. This function expects...

    Please write a code in python! Define and test a function named posterize. This function expects an image and a tuple of RGB values as arguments. The function modifies the image like the blackAndWhite function, but it uses the given RGB values instead of black. images.py import tkinter import os, os.path tk = tkinter _root = None class ImageView(tk.Canvas): def __init__(self, image, title = "New Image", autoflush=False): master = tk.Toplevel(_root) master.protocol("WM_DELETE_WINDOW", self.close) tk.Canvas.__init__(self, master, width = image.getWidth(), height = image.getHeight())...

  • 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...

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