Write an extensible graphical user interface

Assignment Help Computer Graphics
Reference no: EM131925575

The Exercise

Image binarisation is a process used to simplify images for further investigation or simply to reduce the size of an image file. It simply replaces each pixel in an image with one of two possible colours (usually either black or white). The object of this coursework is for you to write an extensible Graphical User Interface (GUI) that can allow a user to load image data, in the form of text files, and perform image binarisation and to save the results.

1. The Image data file formats

There are 3 image file formats to consider in this exercise. All of them are text based and the first line in the file is the name of the format used.

i. Greyscale Image

Each line of data contains information about one pixel.

It has the form x; y; v. Where x; y are the coordinates of the pixel and v is the intensity of the pixel. The intensity ranges from 0 (black) all the way to 255 (white).

Below is the first 5 lines of the file GreyImage.txt.

Greyscale Image

61, 85, 2

69, 8, 21

39, 55, 125

46, 37, 92

2. Colour Image

Each line of data contains information about one pixel.

It has the form x; y; r; g; b. Where x; y are the coordinates of the pixel and r; g; b are the red, green and blue components of the colour.

Below is the first 5 lines of the file ColourImage.txt.

Colour Image

117, 69, 76, 85, 66

7, 126, 82, 63, 56

81, 16, 132, 146, 95

13, 178, 30, 16, 39

Your program must be able to read in files using the above 2 formats. Your program must also be able to write a file in the following Binary Image format:

i. Binary Image

This format has the form x; y; b. Where x; y are the coordinates of the pixel and b is either 0 or 1. Below is the first 5 lines of GreyImageBinaryOutput.txt.

Binary Image

61,85,0

69,8,0

39,55,1

46,37,0

2. Binarisation Methods

For a user selected threshold, t. The binarisation process works as follows:

  • For Greyscale Images if v < t then the output is 0 else it is 1.
  • For Colour Images if r+g+b/3 < t then the output is 0 else it is 1.

Automatically selecting a threshold

Your program is required to suggest a threshold to use. This is calculated in the following way:

  • For Greyscale Images t is the average of all the intensity values (v) from the image.
  • For Colour Images The intensity of a pixel is r+g+b/3. t is the average of all these computed intensity values from the image.

The suggested threshold is int(t), (since t is likely not to be a whole number).

3. Coding the solution

Your solution must follow the specification below:

Display

For the display use 2 canvas widgets, one to show the input image and one to show the result of the binarisation. The pixels in the image are to be displayed using the create_rectangle method.

Above the leftmost canvas have a label that will display the full file name of any succesfully loaded file. Above the rightmost canvas have another label with content Select Threshold (0-255) an entry box and finally a button.

Have a menu item called File which has sub-items load and save, each link to the relevant file manager window.

Once a file has been succefully loaded, its name will be displayed in the leftmost label. The suggested threshold will be computed and placed in the entry box. When the process button is pressed, the binaristaion will occur using the threshold value in the entry box. The result will be displayed in the rightmost canvas.

To successfully complete this coursework you will need to investigate the functionality available in tkinter, specifically research the canvas widget.

4. Code Provided

A structure to your program is already provided for you to download. You must use the structure provided and follow any instructions provided in these files.

  • BinaryConverter.py. This class is your GUI. You can run it and it will create a small window. Read through it carefully. You have been provided with working code to display pixels onto a canvas. The colour a create_rectangle requires is a String that follows a specific format. I have also provided a method called _determineColorValue() for each class of image which will create this String for you.
  • GUIconnect.py. An abstract class which is the parent to both ColourImage.py and GreyScaleImage.py. Read the comments in the method definitions carefully. These provide further instructions of what to write.
  • ColourImage.py and GreyScaleImage.py are where you put code specific to each file format.
  • BinaryImage.py. This class stores the result of the binarisation process and the code for the file format for saving to.

Hint: ColourImage.py, GreyScaleImage.py and BinaryImage.py are missing constructors. You will need to implement them.

Note: You may only import from tkinter. You must not import any other libraries.

Extensibility and Polymorphism

The Graphical User Interface should not be too tightly coded to binarisation approaches and their file formats. In fact we aim to have a situation that if a programmer wishes to include their own file format and binarisation approach they could include it with minimal effort. In addition if the programmer wishes to change the file format for saving the binary image, the code for your GUI (BinaryConverter) should not need to be ammended at all. To achieve this, all image types are implemented as classes that inherit from the abstract class GUIconnect (an abstract class has method definitions but with no usable method bodies). Your Graphical User Interface should communicate with these classes through the methods defined in that abstract class.

Within your Graphical User Interface use polymorphism to make the inclusion of another image file class as simple as possible.

You may always assume that the first line in an image file is a string containing the file type.

Preliminaries

Download fromMoodle BinaryConverter.py, GUIconnect.py, ColourImage.py, GreyScaleImage.py and BinaryImage.py . Place them all in the same directory of your choosing. Read through this code and understand the structure.

Finally download the test data:

GreyImage.txt, ColourImage.txt, GreyImageBinaryOutput.txt, ColourImageBinaryOutput.txt.

  • For GreyImage.txt, the suggested threshold should be 97 and the file output after saving the result is in GreyImageBinaryOutput.txt.
  • For ColourImage.txt, the suggested threshold should be 70 and the file output after saving the result is in ColourImageBinaryOutput.txt.

Attachment:- Assignment Files.rar

Reference no: EM131925575

Questions Cloud

Discuss the importance of system time configuration : Discuss the importance of System Time configuration and why you think this might be of critical importance? Explain what you think would happen
Major challenges associated with removable memory : What are the major challenges associated with removable memory that investigators face?
How can a caregiver foster secure attachment : How can a caregiver foster secure attachment? What are some cultural differences in how parents foster attachment in their children?
Describe the organizational structure and design : Describe the organizational structure and design and Examine the organization's differentiation and growth strategy
Write an extensible graphical user interface : The Exercise - Write an extensible Graphical User Interface (GUI) that can allow a user to load image data, in the form of text files
Describe emerging it and security trends : Describe emerging IT and security trends. How do they impact network security? Are there challenges and advantages by new technologies?
Define sampling bias in general and nonresponse bias : Define sampling bias in general and nonresponse bias in particular. List techniques that can be used to increase the response rate and reduce nonresponse bias.
Identify and describe any interdependencies in the planning : Define, describe and identify the elements of (a) good Website Database Backup Planning and (b) good website Disaster Recovery Planning.
Conduct an investigation onsite : Under what circumstances is a computer forensics investigator required to conduct an investigation onsite and not be able to remove

Reviews

len1925575

4/3/2018 2:00:09 AM

ISD Term 2 Coursework 2. Deadline for submission: Monday 9th at 17:55. Please read the Submitting the assignment section at the end of this document. Second deadline (mark will be capped to pass mark unless there are mitigating circumstances) is Monday 23rd 17:55. Any submissions uploaded after the 2nd deadline will be capped at zero marks.

len1925575

4/3/2018 2:00:01 AM

Marking Scheme - This coursework is marked out of 100 as follows: 20 marks. Producing a Graphical User Interface that fits the specification described above and is extensible. Using object oriented programming and in particular polymorphism within BinaryConverter. 10 marks. Robustness of your user interface to users interacting with it, e.g. your program should not crash if the user types in a name instead of a number for the parameter. 20 marks. Correctly implementing class functionality for BinaryImage. 20 marks. Correctly implementing class functionality for GreyImage. 10 marks. Correctly implementing class functionality for ColourImage.

len1925575

4/3/2018 1:59:54 AM

15 marks. Code Quality. Marks will be awarded for the clarity of your code, this includes the following: Comments. See function comments in Section 5.2, All Classes will need to be commented appropriately see Slide 21 of Chapter 9 (Writing the Public Interface). Appropriate variable, function and argument names. Any hard-coded strings that are used in multiple locations should be defined as constants. 5 marks. Correctly following the assignment submission instructions.

len1925575

4/3/2018 1:59:46 AM

Submitting the assignment: Always keep backup copies of all assignments. If your assignment gets lost, a backup copy will make things easier for you. Include comments in your source code. Include in a comment at the top of each source code file, your name, the name of the programme you are taking (e.g., MSc IT, etc.), and the submission date. Submit one zip file containing only your BinaryConverter.py, ColourImage.py, GreyScaleImage.py and BinaryImage.py . Also include the file GUIconnect.py. To submit your file, follow the Upload Submission for Term2 – Coursework 2 link on the ISD Moodle page.

Write a Review

Computer Graphics Questions & Answers

  Create a simple warm-up program using your g3d

Create a simple warm-up program using your G3D programming and graphics environment.

  Shadow effect while rolling a sphere

Shadow effect while rolling a sphere as well as the options of shading and lighting.

  Relative positioning and interactive positioning

Relative Positioning and Interactive Positioning by Dragging and Clicking and some Simple Animation

  Draw a teapot at the global origin

Draw a teapot at the global origin

  Concepts of computer graphics

Concepts of Computer Graphics and develop a program using OpenGL

  The security policy document outline

Using the GDI Case Study below, complete the Security Policy Document Outline

  Develop the image manipulations

Develop the image manipulations

  What does resolution mean

What does resolution mean How is resolution connected to ppi and dpi units

  Differentiate between a bitmap image and a vector image

Differentiate between a bitmap image and a vector image Explain the following terms

  Essential elements of a design pattern

configuration of an Iterator pattern, patterns could be used in a Library System, Singleton, Template, Decorator, Façade,What does Alexander means by the following declaration "But it is impossible to form anything which has the temperament of natu..

  Framework of user interface design

design of user interfaces, natural mapping, GUI applications, web page design different to designing for printed media, risks exposed in this "phone as individual proxy" approach, interaction designers of ubicomp applications, Storyboards are usual..

  What are the factors affecting picture composition

Define picture composition What are the factors affecting picture composition. Elaborate on each factor Describe the basic lines present in a composition

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd